#32413: File upload permission denied error on large files -------------------------------+-------------------------------------- Reporter: James Miller | Owner: nobody Type: Uncategorized | Status: new Component: Uncategorized | Version: 3.1 Severity: Normal | Resolution: Keywords: | Triage Stage: Unreviewed Has patch: 0 | Needs documentation: 0 Needs tests: 0 | Patch needs improvement: 0 Easy pickings: 0 | UI/UX: 0 -------------------------------+-------------------------------------- Description changed by James Miller:
Old description: > Hi, if an uploaded file exceeds the DATA_UPLOAD_MAX_MEMORY_SIZE of 2.5 > mb, django starts streaming the file data to a file in /tmp. > > When finished it copies it over to the its required file path location, > but despite the permissions being set correctly, a permission denied > error occurs. > > {{{ > Request Method: POST > Request URL: http://127.0.0.1:8000/xxxx/upload/ > Django Version: 3.1.5 > Exception Type: PermissionError > Exception Value: > > [Errno 13] Permission denied: > '/opt/django_forum/django_forum/media/uploads/users/xxxxx > /Albert_Memorial_London_-_May_2008_vWcDQT6.jpg' > > Exception Location: /usr/local/lib/python3.9/shutil.py, line 329, in > _copyxattr > Python Executable: /usr/local/bin/python > Python Version: 3.9.1 > Python Path: > > ['/opt/django_forum/django_forum', > '/opt/django_forum/django_forum', > '/etc/opt/django_forum', > '/opt/django_forum', > '/usr/local/lib/python39.zip', > '/usr/local/lib/python3.9', > '/usr/local/lib/python3.9/lib-dynload', > '/usr/local/lib/python3.9/site-packages'] > }}} > > I have tried setting the following settings: > > {{{ > FILE_UPLOAD_DIRECTORY_PERMISSIONS = 0o755 > FILE_UPLOAD_PERMISSIONS = 0o644 > }}} > Most disturbingly, the files are created in their final position with > 0755 permissions. > > I am using a containerised workflow as opposed to a venv but I am not > certain that that should cause any issues. New description: Hi, if an uploaded file exceeds the DATA_UPLOAD_MAX_MEMORY_SIZE of 2.5 mb, django starts streaming the file data to a file in /tmp. When finished it copies it over to the its required file path location, but despite the permissions being set correctly, a permission denied error occurs. {{{ Request Method: POST Request URL: http://127.0.0.1:8000/xxxx/upload/ Django Version: 3.1.5 Exception Type: PermissionError Exception Value: [Errno 13] Permission denied: '/opt/django_forum/django_forum/media/uploads/users/xxxxx /Albert_Memorial_London_-_May_2008_vWcDQT6.jpg' Exception Location: /usr/local/lib/python3.9/shutil.py, line 329, in _copyxattr Python Executable: /usr/local/bin/python Python Version: 3.9.1 Python Path: ['/opt/django_forum/django_forum', '/opt/django_forum/django_forum', '/etc/opt/django_forum', '/opt/django_forum', '/usr/local/lib/python39.zip', '/usr/local/lib/python3.9', '/usr/local/lib/python3.9/lib-dynload', '/usr/local/lib/python3.9/site-packages'] }}} I have tried setting the following settings: {{{ FILE_UPLOAD_DIRECTORY_PERMISSIONS = 0o755 FILE_UPLOAD_PERMISSIONS = 0o644 }}} Most disturbingly, the large files are created in their final position with 0755 permissions. I am using a containerised workflow as opposed to a venv but I am not certain that that should cause any issues. -- -- Ticket URL: <https://code.djangoproject.com/ticket/32413#comment:1> Django <https://code.djangoproject.com/> The Web framework for perfectionists with deadlines. -- You received this message because you are subscribed to the Google Groups "Django updates" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-updates+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/074.04a94da3097d0582a6905f06f5d89800%40djangoproject.com.