Django

Code

Ticket #8454: 8454.diff

File 8454.diff, 2.1 kB (added by dcwatson, 5 months ago)
  • django/conf/global_settings.py

    old new  
    252252# (i.e. "/tmp" on *nix systems). 
    253253FILE_UPLOAD_TEMP_DIR = None 
    254254 
     255# The numeric mode to set newly-uploaded files to. See the chmod function here: 
     256# http://docs.python.org/lib/os-file-dir.html 
     257FILE_UPLOAD_PERMISSIONS = None 
     258 
    255259# Default formatting for date objects. See all available format strings here: 
    256260# http://www.djangoproject.com/documentation/templates/#now 
    257261DATE_FORMAT = 'N j, Y' 
  • django/core/files/storage.py

    old new  
    168168            else: 
    169169                # OK, the file save worked. Break out of the loop. 
    170170                break 
    171                  
     171 
     172        # Since it's possible that temporary files and in-memory saved files will end up 
     173        # with different permissions, allow for a common way of setting them. 
     174        if settings.FILE_UPLOAD_PERMISSIONS is not None: 
     175            os.chmod( full_path, settings.FILE_UPLOAD_PERMISSIONS ) 
     176 
    172177        return name 
    173178 
    174179    def delete(self, name): 
  • docs/upload_handling.txt

    old new  
    150150        Which means "try to upload to memory first, then fall back to temporary 
    151151        files." 
    152152 
     153    ``FILE_UPLOAD_PERMISSIONS`` 
     154        The numeric mode (e.g. ``0644``) to set newly-uploaded files to. 
     155 
     156        If this is not specified, temporary files will be created with a mode of 
     157        ``0600``, while files saved to disk from memory will respect the current 
     158        umask value. 
     159 
     160        See the `documentation for chmod`_ for a list of mode bits. 
     161 
    153162.. _settings: ../settings/ 
     163.. _documentation for chmod: http://docs.python.org/lib/os-file-dir.html 
    154164 
    155165``UploadedFile`` objects 
    156166========================