Nginx (I think) saves files with wrong permissions when request is too large Nginx (I think) saves files with wrong permissions when request is too large nginx nginx

Nginx (I think) saves files with wrong permissions when request is too large


After struggling with this issue myself I figured it out. AlexD's theory of large files being handled differently is correct.

From Django's documentation:

FILE_UPLOAD_PERMISSIONS

Default: None

The numeric mode (i.e. 0o644) to set newly uploaded files to. For more information about what these modes mean, see the documentation for os.chmod().

If this isn’t given or is None, you’ll get operating-system dependent behavior. On most platforms, temporary files will have a mode of 0o600, and files saved from memory will be saved using the system’s standard umask.

So in summary: larger files are stored using temporary files, which will get 0o600 permissions by default. The problem can easily be fixed by setting a value to FILE_UPLOAD_PERMISSIONS.

https://docs.djangoproject.com/en/1.11/ref/settings/#file-upload-permissions