meringue.core.upload_handlers ¤
rename_handler ¤
Default method for renaming files when using load handlers MemoryFileUploadHandler and / or TemporaryFileUploadHandler.
Attributes:
-
file_name
–Original file name.
Returns:
-
str
–New file name.
Source code in meringue/core/upload_handlers.py
def rename_handler(file_name: str) -> str:
"""
Default method for renaming files when using load handlers
[MemoryFileUploadHandler][meringue.core.upload_handlers.MemoryFileUploadHandler] and / or
[TemporaryFileUploadHandler][meringue.core.upload_handlers.TemporaryFileUploadHandler].
Attributes:
file_name: Original file name.
Returns:
New file name.
"""
return str(Path(file_name).with_stem(str(uuid.uuid4())))
MemoryFileUploadHandler ¤
Bases: MemoryFileUploadHandler
File upload handler to stream uploads into memory (used for small files).
Examples:
settings.py
FILE_UPLOAD_HANDLERS = (
'meringue.core.upload_handlers.MemoryFileUploadHandler',
'django.core.files.uploadhandler.TemporaryFileUploadHandler',
)
TemporaryFileUploadHandler ¤
Bases: TemporaryFileUploadHandler
Upload handler that streams data into a temporary file.
Examples:
settings.py
FILE_UPLOAD_HANDLERS = (
'django.core.files.uploadhandler.MemoryFileUploadHandler',
'meringue.core.upload_handlers.TemporaryFileUploadHandler',
)