I am trying to upload a fil to S3 without using a custom backend. This is what I have so far:
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
And I get the following error:
TypeError at /qc/86/
coercing to Unicode: need string or buffer, InMemoryUploadedFile found
How would I correctly upload a file from request['FILES'] to s3 without using a custom storage backend?
I faced a similar issue a while back instead of using
set_contents_from_filename(f)tryk.set_contents_from_string(f.read())I did the same thing in this project here: https://github.com/buddylindsey/developerrage/blob/master/developerrage/comic/views.py