starou / django-thumborstorage Goto Github PK
View Code? Open in Web Editor NEWDjango storage backend for Thumbor
License: MIT License
Django storage backend for Thumbor
License: MIT License
image_file.width
raises AttributeError: 'File' object has no attribute 'width'
Hi,
Response status code isn't checked after saving image file into thumbor server. ThumborStorageFile.write
Thumbor server can respond with several HTTP statuses thumbor doc
If upload wasn't successful code fails on exception
File "/usr/lib/python2.7/site-packages/django_thumborstorage/storages.py", line 102, in _save f.write(content=content) File "/usr/lib/python2.7/site-packages/django_thumborstorage/storages.py", line 46, in write self._location = unquote(response.headers["location"]) File "/usr/lib/python2.7/site-packages/requests/structures.py", line 54, in __getitem__ return self._store[key.lower()][1] KeyError: 'location'
Can we check response status and raise proper exception based on it?
e.g. 415 Unsupported Media Type can be ValidationError maybe
This change in Django 3.2.11 django/django@6d343d0 appears to break ThumborStorage. When uploading files I get a failure and the following exception:
django.security.SuspiciousFileOperation Detected path traversal attempt in '/image/8d7e08134015fc0430fbc3b484d424cd/test.png'
Wontfix since I don't want to import setup from setuptools
.
I'm running into a UnicodeEncodeError
when I try to save a file with non-ascii characters in the file name. A solution would be to utf-8 encode the name here. I'm using Django 1.6.10, Python 2.7 and django-thumborstorage 0.91.7. To reproduce:
from django.core.files.base import ContentFile
from django_thumborstorage.storages import ThumborStorage
storage = ThumborStorage()
storage.save(u'‘Ø', ContentFile(''))
I'm happy to implement a fix and open a PR.
if re.match(r"^/image/\w{32}/.*$", name):
return True
Content Type is hard-coded at jpeg...
The deconstructible
import here raises ImportError
in Django 1.6 since migrations were only introduced in Django 1.7. Can I open a PR to fix it?
Some projects I work on are currently pinned to version 1.9.12
, which appears to have vanished from PyPi, is this intentional? Is there a reason for this?
I've got a version of 1.9.12
installed locally, but when trying to install from TravisCI, I get this message:
Could not find a version that satisfies the requirement django-thumborstorage==1.9.12 (from -r requirements.txt (line 14)) (from versions: 0.91.1, 0.91.2, 0.91.3, 0.91.4, 0.91.5, 0.91.6, 0.91.7, 0.91.8, 0.92.0, 1.11.1)
No matching distribution found for django-thumborstorage==1.9.12 (from -r requirements.txt (line 14))
This version number looks very similar to 0.91.2
, was there just a version numbering change?
Hi,
I found this issue when I optimised our production setup.
Configuration we use is django -> ThumborStorageFile -> Thumbor server -> S3 bucket (as image storage)
# django model
class Image(models.Model):
checksum = models.CharField(max_length=40, unique=True, db_index=True)
image = models.ImageField(
upload_to='image/',
storage=ThumborStorage(),
height_field='height',
width_field='width'
)
height = models.IntegerField(blank=True, null=True, db_index=True)
width = models.IntegerField(blank=True, null=True, db_index=True)
Upload image workflow (save method):
ThumborStorageFile.write
methodThumborStorageFile. _get_image_dimensions
class ThumborStorageFile(ImageFile):
file = property(_get_file, _set_file)
def close(self):
self._file = None # pointer to file is removed
super(ThumborStorageFile, self).close()
# parent method touch file property which will cause a new file download.
# parent method from class File
def close(self):
self.file.close()
# self.file goes to self._get_file which reads from self._file
# because self._file == None _get_file starts a new download from thumbor server
# the only method called on fresh downloaded image is .close() :-(
If you feel this is something you want to maintain let me know and I'll put it in thumbor's wiki as a plugin :)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.