def save_image_to_s3(self):
"""TODO"""
import boto
s3_connection = boto.connect_s3()
bucket = s3_connection.get_bucket('endorsementdb.com')
url = self.get_large_image()
response = requests.get(url, stream=True)
with open('/tmp/profile_image.png', 'wb') as out_file:
shutil.copyfileobj(response.raw, out_file)
del response
key = bucket.new_key('images/endorsers/%d.png' % self.endorser.pk)
key.set_contents_from_filename(out_file.name)
key.make_public()
评论列表
文章目录