django-filer icon indicating copy to clipboard operation
django-filer copied to clipboard

Cannot upload SVG

Open lmanzurv opened this issue 8 years ago • 4 comments

Hi,

I tried creating a Django CMS plugin for uploading SVG images. I followed the instructions under extending Django Filer, but using File as base, not BaseImage. On my local machine (using SQLite and local file storage) it works, but when I try to use the production setup (PostgreSQL + AWS S3), it breaks. In the error log I noticed that the MultiStorageFieldFile uses Thumbnailer which, when trying to save, throws the error StringIO instance has no attribute 'size' (I think it may have to with the fact that I'm using Django 1.8.9 because it breaks in a line self._size = content.size which is no longer in the latest Django version). Because of this, I cannot upload SVG files (nor from my plugin nor from the generic File definition inside filer).

Not actually sure if it's filer that's causing it because of Thumbnailer or if it's Django. Could you shed me some light?

lmanzurv avatar Jul 06 '16 02:07 lmanzurv

The problem is possibly that gzip is activated for SVG files on S3. So the thumbnailer gets a gzip stream which it can't handle. As a workaround disable gzip for SVG files.

melbic avatar Jul 06 '16 07:07 melbic

OMG!! That was it! Django-storages had GZIP on and the default config compresses SVGs! And for what I saw, that's new. I just redefined the GZIP setting to exclude SVGs and it worked! Thank you very much!

lmanzurv avatar Jul 06 '16 11:07 lmanzurv

You can now upload images? and attach them to other tables using a CSV? PLEASE OH GOD PLEASE HELP ME

10featj avatar Mar 29 '17 15:03 10featj

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Jul 28 '22 22:07 stale[bot]

This will now be closed due to inactivity, but feel free to reopen it.

stale[bot] avatar Aug 31 '22 00:08 stale[bot]