0
我調整使用PIL在S3但問題在保存調整大小的文件上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.
你不應該在'k.set_contents_from_file(file)'行中使用'self.file'而不是'file'嗎? –
@MichielOvertoom我只是從我的代碼複製主線,self.file是原始圖像,而我很想保存調整大小的圖像。我會編輯我的問題 – user5594493