Storing images and thumbnails on s3 in django

前端 未结 3 1678
后悔当初
后悔当初 2021-01-30 09:50

I\'m trying to get my images thumbnailed and stored on s3 using django-storages, boto, and sorl-thumbnail. I have it working, but it\'s very slow, even with small images. I don\

3条回答
  •  春和景丽
    2021-01-30 10:04

    As the author of sorl thumbnail I am really interested in solving this if it is not working as I intended. If the key value sotre is populated it will currently store: name, storage and size. I have made the assumption that the url is based on the name and thus should not cause any storage calls. Looking at django storages, https://github.com/e-loue/django-storages/blob/master/storages/backends/s3boto.py#L214 it seems like a safe assumption to make. In your patch you have patched the read method for some reason. When creating a thumbnail a ImageFile instance is fetched from cache (if not create it) then you can of course call read which will read the file, but the intended use is .url which calls url on the storage with the cached name which inturn should be a non storage access op. Could you try to isolate your problem to exacly where in your code this storage access happends?

    Also make sure you have THUMBNAIL_DEBUG on and that you have the key value store properly set up.

自定义标题
段落格式
字体
字号
代码语言
提交回复
热议问题