Upload resized image to S3

前端 未结 3 2025
失恋的感觉
失恋的感觉 2020-12-23 22:34

I\'m trying to upload resized image to S3:

fp = urllib.urlopen(\'http:/example.com/test.png\')
img = cStringIO.StringIO(fp.read())

im = Image.open(img)
im2          


        
3条回答
  •  孤独总比滥情好
    2020-12-23 23:01

    My guess is that Key.set_contents_from_filename expects a single string argument, but you are passing in im2, which is some other object type as returned by Image.resize. I think you will need to write your resized image out to the filesystem as a name file and then pass that file name to k.set_contents_from_filename. Otherwise find another method in the Key class that can get the image contents from an in-memory construct (StringIO or some object instance).

提交回复
热议问题