Trying to migrate from boto2 and previously was using the boto.s3.generate_url method which took a parameter response_headers.
Am now attempting to use S3.Client.generate_presigned_url which no longer has this parameter.
How would I go about passing these in boto3?
The Params parameter in S3.Client.generate_presigned_url (as well as its cousin in botocore) are the droids you are looking for. :-)
Thanks for the response managed to get it working with your advice :)
For anyone else who comes across this in when doing a boto2 -> boto3 port you would translate as follows:
boto2
signed_url = connection.generate_url(
expires_in = 60,
method = "GET",
bucket = "mybucket",
key = s3_key,
response_headers = {
"response-content-disposition": "attachment; filename=report.pdf",
"response-content-type": "application/pdf"
}
)
boto3
signed_url = client.generate_presigned_url(
ClientMethod = "get_object",
ExpiresIn = 60,
Params = {
"Bucket": "mybucket",
"Key": s3_key,
"ResponseContentDisposition": "attachment; filename=report.pdf",
"ResponseContentType" : "application/pdf"
}
)
:+1: The force is strong with this one. :)
Hi, I'm using boto3 and trying to use params ResponseContentType, ResponseContentDisposition but it cause SignatureDoesNotMatch error. This error not appeared when I don't specify these params.
Most helpful comment
Thanks for the response managed to get it working with your advice :)
For anyone else who comes across this in when doing a
boto2->boto3port you would translate as follows:boto2
boto3