Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Thumbnail tag in Google Appengine #1922

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

jesteria
Copy link

@jesteria jesteria commented May 7, 2019

Improve compatibility of thumbnail tag with remote storage backends (Google Cloud Storage) and filesystem-less deployments (Appengine)

The thumbnail tag doesn't work on Google Appengine (GAE) without
these changes -- in that environment, the file system is mounted
read-only, and as such generated thumbnail images cannot be written to
it, (even temporarily).

Moreover, the pre-existing check for already-generated thumbnails
assumed a FileSystemStorage backend, (and indeed went around it); as
such, thumbnails were regenerated upon every request. These changes
leverage the file storage backend for this check, for more generalized
and optimized compatibility.


To note, the thumbnail function is also made to rely more completely on
the default storage backend when saving -- refactoring this block
slightly -- to simply use default_storage.open(). This features
compatibility with both remote and local storage backends, without
additional work.


Finally, this change set updates the AUTHORS file, (in line with
contribution guidelines).

…ds (Google Cloud Storage) and filesystem-less deployments (Appengine)

The ``thumbnail`` tag doesn't work on Google Appengine (GAE) without
these changes -- in that environment, the file system is mounted
read-only, and as such generated thumbnail images cannot be written to
it, (even temporarily).

Moreover, the pre-existing check for already-generated thumbnails
assumed a FileSystemStorage backend, (and indeed went around it); as
such, thumbnails were regenerated upon every request. These changes
leverage the file storage backend for this check, for more generalized
and optimized compatibility.

---

To note, the thumbnail function is also made to rely more completely on
the default storage backend when *saving* -- refactoring this block
slightly -- to simply use ``default_storage.open()``. This features
compatibility with both remote and local storage backends, without
additional work.

---

Finally, this change set updates the AUTHORS file, (in line with
contribution guidelines).
cannot presume even that default_storage.open() and
TemporaryFile/SpooledTemporaryFile will be enough for PIL image.save;
rather, necessary to write thumbnail image to memory, first.
@jesteria
Copy link
Author

Note, the thumbnail tag had to be made to initially save the thumbnail to a BytesIO shim, for much the same reason of environmental compatibility.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant