Give the FileField 'upload_to' callable access to an UploadedFile's contents.
|Reported by:||Pyth||Owned by:||nobody|
|Severity:||Normal||Keywords:||feature upload_to FileField|
|Has patch:||no||Needs documentation:||yes|
|Needs tests:||yes||Patch needs improvement:||yes|
FileField.upload_to allows for a callable and requests an instance and a filename. Because it may be of interest to the programmer to use the file's content (MD5 sum, MIME type, ID3 tags etc.) in the upload path, it would be handy to be able to access it from the callable method.
One possibility would be to pass an UploadedFile instead of a filename but this would break the compatibility policy in 1.0.X. Temporarily, this functionality could be added via an uploaded_file or content property added to the instance (in FieldFile.save()), making it accessible from the upload_to(instance, filename) callable with instance.uploaded_file.
I'll throw up some patches if this makes any sense.
Change History (11)
comment:1 Changed 7 years ago by Pyth
- Needs documentation set
- Needs tests set
- Patch needs improvement set
- Triage Stage changed from Unreviewed to Design decision needed
comment:9 Changed 22 months ago by mlavin
- Resolution set to wontfix
- Status changed from new to closed