我想上传一个文件到S3,但不使用自定义后端。以下是我的尝试:
conn=boto.connect_s3(settings.AWS_KEY, settings.AWS_SECRET)
bucket=conn.get_bucket(settings.AWS_BUCKET)
k = Key(bucket)
filename = f.name
keyname = str(int(uuid.uuid4()))[:10] + filename
k.key = keyname
k.set_contents_from_filename(f)
url = "https://s3.amazonaws.com/.../" + keyname
我遇到了以下错误:
TypeError at /qc/86/
coercing to Unicode: need string or buffer, InMemoryUploadedFile found
如何在不使用自定义存储后端的情况下,正确地从request['FILES']
上传文件到S3?