Hi,
The `FileSystemStorage._save()` method seems to implicitly close the
uploaded file after it's been saved, preventing the following from
working:
storage.save('/images/image.gif', uploaded_image) # Store the original
thumbnail = Image.open(uploaded_image) # Doesn't work because
uploaded_image was closed or not reset.
Should that 'close-original-after-storing' behaviour be enforced
across all file storage systems, or should that be left to the
individual systems (like currently with `FileSystemStorage`) to
decide?
Instead, another possibility would be to leave it to the developer to
decide what she wants to do with the original uploaded file instance.
For example:
storage.save('/images/image.gif', uploaded_image) # Store the
original, and leave it open.
thumbnail = Image.open(uploaded_image)
.... # Manipulate thumbnail
storage.save('/images/thumbnail.gif', thumbnail) # Store thumbnail
uploaded_image.close()
thumbnail.close()
To be clear, here `uploaded_image` and `thumbnail` do not directly
refer to the stored versions (which might be somewhere on S3 or
wherever), but to the "temporary" versions that are either in memory
or in temporary files.
In my opinion, the above example would be more explicit and feel more
logical from the developer's point of view. See also #8222, which I'm
starting to question the validity, for a related question.
Thanks for your thoughts on this.
Regards,
Julien
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/django-developers?hl=en
-~----------~----~----~----~------~----~------~--~---