Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Nginx/Django File Upload Permissions

Today I noticed that whenever I upload a file through my Django site the file is uploaded with the file permissions 0600 meaning whenever a non root user wants to view the file (nginx) a 403 is shown.

This only started happening today from what I can tell. I have checked both the file_upload_permissions and file_upload_directory_permissions in the Django settings file and they are both set to 0644.

I haven't done any Linux/Django updates recently so that shouldn't be the cause, any help would be greatly appreciated.

Thanks,

Sam

like image 230
samroberts707 Avatar asked Jan 04 '23 21:01

samroberts707


1 Answers

If you have recently switched to Python 3, please take a look at here for a reference to octal literals in Python 3. Changing your settings as follows should fix it:

FILE_UPLOAD_PERMISSIONS = 0o644

This is also helpful in writing Python 2-3 compatible code.

like image 79
McMutton Avatar answered Jan 08 '23 07:01

McMutton