How can I upload file (that I get from formdata with AJAX) to S3 using boto? I'm trying to do this, but it doesn't work.
def upload_file(self, file):
conn = S3Connection('xxxxxxxxxxxx', 'xxxxxxxxxxxx')
bucket = conn.get_bucket('xxxxxxxx', validate=False)
k = Key(bucket)
k.key = file.filename
k.set_contents_from_stream(f.body)
k.set_metadata('Content-Type', 'application/pdf')
k.set_acl('public-read')
url = k.generate_url(expires_in=0, query_auth=False)
return url