1. 程式人生 > >Django上傳檔案的那些引數

Django上傳檔案的那些引數

# ################## 預設檔案上傳配置 ########################
from django.core.files.uploadhandler import MemoryFileUploadHandler
from django.core.files.uploadhandler import TemporaryFileUploadHandler

# List of upload handler classes to be applied in order.
FILE_UPLOAD_HANDLERS = [
    'django.core.files.uploadhandler.MemoryFileUploadHandler
', 'django.core.files.uploadhandler.TemporaryFileUploadHandler', ] # Maximum size, in bytes, of a request before it will be streamed to the # file system instead of into memory. # 允許記憶體中上傳檔案的大小 # 合法:InMemoryUploadedFile物件(寫在記憶體) -> 上傳檔案小於等於 FILE_UPLOAD_MAX_MEMORY_SIZE # 不合法:TemporaryUploadedFile物件(寫在臨時檔案) -> 上傳檔案大於 FILE_UPLOAD_MAX_MEMORY_SIZE 且 小於 DATA_UPLOAD_MAX_MEMORY_SIZE
FILE_UPLOAD_MAX_MEMORY_SIZE = 2621440 # i.e. 2.5 MB # Maximum size in bytes of request data (excluding file uploads) that will be # read before a SuspiciousOperation (RequestDataTooBig) is raised. # 允許上傳內容的大小(包含檔案和其他請求內容) DATA_UPLOAD_MAX_MEMORY_SIZE = 2621440 # i.e. 2.5 MB # Maximum number of GET/POST parameters that will be read before a
# SuspiciousOperation (TooManyFieldsSent) is raised. # 允許的上傳檔案數 DATA_UPLOAD_MAX_NUMBER_FIELDS = 1000 # Directory in which upload streamed files will be temporarily saved. A value of # `None` will make Django use the operating system's default temporary directory # (i.e. "/tmp" on *nix systems). # 臨時資料夾路徑 FILE_UPLOAD_TEMP_DIR = None # The numeric mode to set newly-uploaded files to. The value should be a mode # you'd pass directly to os.chmod; see https://docs.python.org/3/library/os.html#files-and-directories. # 檔案許可權 FILE_UPLOAD_PERMISSIONS = None # The numeric mode to assign to newly-created directories, when uploading files. # The value should be a mode as you'd pass to os.chmod; # see https://docs.python.org/3/library/os.html#files-and-directories. # 資料夾許可權 FILE_UPLOAD_DIRECTORY_PERMISSIONS = None