Downloading and manipulating images in Django

I am trying upload images and than create an thumbnail of it and than store both in S3. After the file has been uploaded i am first uploading it to S3 and than trying to create thumbnail but it doesn’t work as than PIL is not able to recognise the image. And secondly if I create the thumbnail first than while uploading original image I get EOF.

I think Django allows just once for the uploaded files to be used only once….Please kindly tell me a way to do so….Thanks in advance

Uhm, you need to be more specific with your question, but we’re doing the same thing and the workflow is as follows:

1) You get the file handle on file upload from request.FILES and store it somewhere on your local filesystem, so you don’t work on stream — which is what i would guess is causing your problems

2) You use PIL (or better yet, Pillow) to manipulate the image on the FS, do resizing, thumbnailing, whatever.

3) You use Boto (http://boto.cloudhackers.com/en/latest/) to upload to S3, because Boto takes the handling of AWS out of your hands.

It’s quite straightforward and works well

Hello, buddy!稿源:Hello, buddy! (源链) | 关于 | 阅读提示

本站遵循[CC BY-NC-SA 4.0]。如您有版权、意见投诉等问题,请通过eMail联系我们处理。
酷辣虫 » 综合编程 » Downloading and manipulating images in Django

喜欢 (0)or分享给?

专业 x 专注 x 聚合 x 分享 CC BY-NC-SA 4.0

使用声明 | 英豪名录