models.py 文件源码

python
阅读 30 收藏 0 点赞 0 评论 0

项目:endorsementdb.com 作者: endorsementdb 项目源码 文件源码
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()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号