I'm attempting to use presigned S3 URLs to PUT/GET a file via requests
but an getting additional information in the uploaded file:
This is another Test Document!
The uploaded file will look like:
--424232468bf0c117eea367b5410bbcd7
Content-Disposition: form-data; name="file"; filename="my_test3.txt"
This is another Test Document!
--424232468bf0c117eea367b5410bbcd7--
Is there any reason the hash and Content-Disposition would be appearing in the uploaded file?
params = {
'Bucket': bucket_name,
'ContentType': content_type,
'Key': object_name
}
if encode:
params['ContentEncoding'] = encode
# do_client is a boto3.session.Session(...)
return do_client().generate_presigned_url(
ClientMethod='put_object',
Params=params,
ExpiresIn=600
)
Code to put the file onto the server:
headers = {
'Content-Type': content_type,
}
if content_encoding:
headers['Content-Encoding'] = content_encoding
files = {'file': f} # f is an open() file handle
r = requests.put(
put_url,
headers=headers,
files=files
)
Perhaps I misunderstand something about the object uploading process? I've tested without using the presigned URLs (via the storages
lib for django) and everything uploaded as expected.