Problems with thumbnails in S3

483 views
Skip to first unread message

Eric Marcos

unread,
Apr 24, 2013, 2:12:00 PM4/24/13
to django...@googlegroups.com
Hi,

I'm trying to set up my S3 storage backend with django-filer. When I upload an image through the filer admin interface the image is actually uploaded (I can see it in my bucket/filer_public/...), however, what I see on the clipboard is "undefined" and no icon of the image. I can't see the preview in the Change Image view neither, although the link "Full size preview" is right and when I click it I can see the image from S3.
Looks like the only problem is that easy_thumbnails is not able to upload the files to S3, I've tried many different settings (like setting THUMBNAIL_DEFAULT_STORAGE) but nothing works, and anyway, I think the defaults should work out of the box.
I'm using django-filer 0.9.4, Django 1.4.3, easy_thumbnails 1.2 and Python 2.7.

Any help will be highly appreciated.

Eric

Eric Marcos

unread,
Apr 24, 2013, 2:19:41 PM4/24/13
to django...@googlegroups.com
My settings:

####### S3 Storage setup ########
DEFAULT_FILE_STORAGE = 'storages.backends.s3boto.S3BotoStorage'
STATICFILES_STORAGE = 'storages.backends.s3boto.S3BotoStorage'
AWS_ACCESS_KEY_ID = os.environ.get('AWS_ACCESS_KEY_ID')
AWS_SECRET_ACCESS_KEY = os.environ.get('AWS_SECRET_ACCESS_KEY')
AWS_STORAGE_BUCKET_NAME = os.environ.get('AWS_STORAGE_BUCKET_NAME')

Stefan Foulis

unread,
Apr 24, 2013, 4:17:43 PM4/24/13
to django...@googlegroups.com
I had a very similar issue with an other storage backend similar to s3. In my case the problem was, that the storage backend consumed the file object when uploading it and then left the file open with the pointer at the end of the file.

My quick workaround was to do a seek(0) on the file right after saving it the first time.
I'm curious if this feature branch solves your problem as well: https://github.com/stefanfoulis/django-filer/commits/feature/cmscloud-compat

That being said, I used django-filer with S3 on heroku a while back and had no issues with the thumbnails.

cheers
stefan

Eric Marcos

unread,
Apr 24, 2013, 6:37:08 PM4/24/13
to django...@googlegroups.com
Hi Stefan,

thanks for your quick answer. I uploaded my app to heroku and it worked like a charm with the default configuration (yay!).
There must be something wrong with my local setup but I can't figure out what it is. I tried different versions of all the libraries (also the csmcloud-compat branch) but the problem is still there.
Just for the record, here's the traceback of the error I get when uploading files with the filer ajax uploader:

Traceback:
File "/home/eric/.virtualenvs/realstate_local/local/lib/python2.7/site-packages/django/core/handlers/base.py" in get_response
 
111. response = callback(request, *callback_args, **callback_kwargs)
File "/home/eric/.virtualenvs/realstate_local/local/lib/python2.7/site-packages/django/views/decorators/csrf.py" in wrapped_view
 
77. return view_func(*args, **kwargs)
File "/home/eric/.virtualenvs/realstate_local/local/lib/python2.7/site-packages/filer/admin/clipboardadmin.py" in ajax_upload
 
88. 'thumbnail': file_obj.icons['32'],


Exception Type: KeyError at /admin/filer/clipboard/operations/upload/
Exception Value: '32'
Request information:
GET
:
qqfile
= u'13607743457586GC.A.1064.001E.jpg'

for some reason the thumbnails are not being created. I'll let you know if I find the answer.

Anyway, thanks for helping and for developing this great app!!

Eric

Stefan Foulis

unread,
Apr 25, 2013, 2:23:41 AM4/25/13
to django...@googlegroups.com
Hi Eric

The error indicates, that the thumbnail could not be generated.
The error handling in django-filer still sucks is this regard. I'll have to find a good compromise that the system explodes with a reasonable error and traceback when there is something wrong with the environment, but still fails gracefully if someone just uploads a faulty image file.

There are a few things that could have gone wrong:
 - the easy-thumbnails tables could be missing (syncdb / migrate them)
 - PIL could be compiled without JPEG/PNG support  ( make sure the system dependencies are installed and make sure PIL finds them. Maybe try using Pillow instead of PIL, it usually works better)

cheers
stefan

Eric Marcos

unread,
Apr 26, 2013, 7:28:18 PM4/26/13
to django...@googlegroups.com
You're right, I compiled PIL (Pillow) without JPEG support =/

Thanks again! =)
Reply all
Reply to author
Forward
0 new messages