Created
February 16, 2016 12:31
-
-
Save abithyzis/f18d8ddd980ce0e53d3d to your computer and use it in GitHub Desktop.
Django AppEngine compatible url to ImageField
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import requests | |
| from StringIO import StringIO | |
| from django.core.files.uploadedfile import InMemoryUploadedFile | |
| response = requests.get(url) | |
| img_io = StringIO(response.content) | |
| thumb_file = InMemoryUploadedFile(img_io, None, file_name, 'image/jpeg', img_io.len, None) | |
| new_video = Video() | |
| new_video.thumb.save(file_name, thumb_file) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment