Here is how to do that via the Django shell:
url = "http://media.buffalonews.com/smedia/2009/07/20/07/646-0720homelife.standalone.prod_affiliate.50.JPG";
import os
original_filename = os.path.basename(url)
fp = urllib.urlopen(url)
imgstr = cStringIO.StringIO(fp.read())
storage = S3Storage()
img = My_Image()
path = S3Storage.save(storage, original_filename, ContentFile(imgstr.getvalue()))
import Image
pilimg = Image.open(imgstr)
img.image = path
img.width = pilimg.size[0]
img.height = pilimg.size[1]
img.save()
I am using the S3Storage library to store my images.
No comments:
Post a Comment