Django / file uploads permissions

22,206

Try this in your settings.py if you use Python 2:

FILE_UPLOAD_PERMISSIONS = 0644

In Python 3 octal numbers must start with 0o so the line would be:

FILE_UPLOAD_PERMISSIONS = 0o644

For more details see the documentation.

Share:
22,206
z3a
Author by

z3a

Electronic artist, web designer/coder.

Updated on July 09, 2022

Comments

  • z3a
    z3a almost 2 years

    I wrote a django app, but I have a little problem with the file permissions of the uploads files from a web form.

    Basically I can upload a .mp3 file but it always keep chmod 600.

    The container folder has chmod 775, and the umask is set to 022.

    I'm in a shared hosting service.

  • Akseli Palén
    Akseli Palén over 11 years
    In case someone needs the link to the docs: docs.djangoproject.com/en/dev/ref/settings/…
  • Sencer H.
    Sencer H. over 10 years
    This is helps me too... Thank you.
  • jozxyqk
    jozxyqk over 8 years
    Numbers starting with 0 are base 8. The prefix 0o is an alternative, that the docs mention.
  • Caumons
    Caumons over 7 years
    In python 3 octal numbers must start with 0o so the line would be: FILE_UPLOAD_PERMISSIONS = 0o644
  • paradox
    paradox over 6 years
    when I try to print my setting.UPLOAD_FILE_PERMISSIONS, it is null?