我正在尝试将调整大小的图像上传到 S3:
fp = urllib.urlopen('http:/example.com/test.png')
img = cStringIO.StringIO(fp.read())
im = Image.open(img)
im2 = im.resize((500, 100), Image.NEAREST)
AK = 'xx' # Access Key ID
SK = 'xx' # Secret Access Key
conn = S3Connection(AK,SK)
b = conn.get_bucket('example')
k = Key(b)
k.key = 'example.png'
k.set_contents_from_filename(im2)
但我收到一个错误:
in set_contents_from_filename
fp = open(filename, 'rb')
TypeError: coercing to Unicode: need string or buffer, instance found