Skip to content

Instantly share code, notes, and snippets.

@alexlovelltroy
Last active December 13, 2015 17:19
Show Gist options
  • Save alexlovelltroy/4947208 to your computer and use it in GitHub Desktop.
Save alexlovelltroy/4947208 to your computer and use it in GitHub Desktop.
fixed
#DEFAULT_FILE_STORAGE = 'storages.backends.s3boto.S3BotoStorage'
image_request = requests.get(url)
content_type=image_request.headers['content-type']
filename = 'blarg'
if content_type == 'image/jpeg':
filename = "blarg.jpg"
if content_type == 'image/png':
filename = "blarg.png"
image_file = SimpleUploadedFile(
filename,
image_request.content,
content_type=content_type
)
print image_file.__dict__
avtr.avatar.save(image_file.name, image_file) # avtr.avatar is an ImageField
avtr.save()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment