我正在使用PIL在S3上调整图像大小,但是它给出了错误
*** AttributeError: 'bytes' object has no attribute 'tell'
这是我的代码:
image = Image.open(self.file)
resized_image = image.resize((200,200), Image.ANTIALIAS)
bucket = s3_connection()
k = Key(bucket)
filepath = '{0}/{1}'.format(filepath,filename) # filepath & filename values will be received
k.key = '{0}/{1}'.format('media', filepath)
k.set_contents_from_file(resized_image.tobytes()) <- This line is raising the above error.
答案 0 :(得分:0)
需要使用set_contents_from_string()
代替set_contents_from_file()
有关详细信息,请参阅此问题Upload resized image to S3