boto / botocore

The low-level, core functionality of boto3 and the AWS CLI.
Apache License 2.0
1.51k stars 1.09k forks source link

How to create presigned url for CloudFront by specified the Content-Type? #1341

Closed jiamo closed 6 years ago

jiamo commented 6 years ago

With generate_presigned_post(Bucket, Key, Fields=None, Conditions=None, ExpiresIn=3600) in class S3PostPresigner, The Fields can pass Content-Type as a key.

While for CloudFront I also need to set the content-type of file while I don't want to set a again after upload by the presigned url which generated by CloudFrontSigner 's generate_presigned_url.

Is there a easy way to do it? This may be feature request?

joguSD commented 6 years ago

What operation are you trying to create a presigned URL for?

It'd be great if you could post a minimal example of what you're currently trying.

jiamo commented 6 years ago
cf_signer = CloudFrontSigner(key_id, rsa_signer)
cf_signer.generate_presigned_url(url, date_less_than=date_less_than)

I creathe the presigned url for user to upload file to s3 and I need the right Content-Type in s3.

patrickf55places commented 6 years ago

I would like to extend this to pass any custom header. I use it to authenticate using IAM. I use a custom header to protect against some replay attacks (basically, I do what Vault does) on the sts:GetCallerIdentity API.

JordonPhillips commented 6 years ago

Unfortunately the CloudFront presigned url spec does not allow for presigning headers, so this is not something we will be able to support.

xchux commented 2 years ago

@JordonPhillips According to custom-policy whether possible could setting parameters of response-content-type in presigned url to get response with header Content-Type? Or needed to setting something in AWS?