How to set type for uploading file to S3? - amazon-s3

I try to upload gif to AWS S3. URL is presigned. For presign I use Vapor for sending image it happens from React.
Here docs says: https://soto.codes/2020/12/presigned-urls.html
If you want to include some headers values with the URL you have to include the headers while signing it and the client will be required to include exactly the same headers when they use the URL.
but image/gif is sent at presign. In the return of presign I see X-Amz-SignedHeaders: content-type%3Bhost%3Bx-amz-acl.
Seems presign did his part.
Then the content upload, with PUT has also has the Content-Type: image/gif
Then what is wrong. Why S3 does not have the type?
No type here:

Just realised you are looking at the wrong thing. Scroll further down on the aws console page until you find the metadata section. You can also test this by running a get on the object and see what content-type is returned

Related

How to add Content-Disposition response header for AWS CloudFront

I have a Content Distribution Network served by AWS CloudFront.
Some of my clients want to download this file with a specific filename, so I guess that the natural solution will be injecting a Content-Disposition response header.
For example, I can use a query parameter filename for my CloudFront URL so that this file can be downloaded with the name awesome.png
https://XXX.cloudfront.net/abc.png?filename=awesome.png
Then all I have to do is to add the Content-Disposition header to its response.
I thought that it can be easily handled by CloudFront Function or Lambda#Edge, but I found that they cannot solve my problem. It's because the query string filename is in the HTTP request, but the Content-Disposition header must be injected in the HTTP header.
Can anyone suggest a working solution?

S3/Cloudfront does not send image/jpeg Content-Type

I have a .jpg file stored in S3 and distributed using CloudFront. I can view the file when I download it, but I cannot view the file in Chrome or Safari. From what I can tell, I can't view the file in a browser because the Content-Type isn't getting sent despite the fact that I've set it in S3.
You can see what happens when you enter this signed CloudFront url into a browser. It should remain valid for roughly 24 hours after this post. https://media.development.doctheapp.com/claims/us-east-1:4877c3da-786a-4b3b-b1e0-c70bde0f9c4e741afc7c5a8304564963080a98e5675d09d1aca3d623911e34bd3b4eb0808579/300ae913-8f88-44b9-a4ab-e46d11133c76/receipt.jpg?Expires=1526533530&Signature=crnjhje1noP-7WfBMI6rMDPd-zdCAVKLaojFFNvxCZEdx0~EJHeqbL8oKwL64AULavekMHm~2r6vHto1d4IAt5eoLpbZR~q5PAfhSakte1iNNvuTxQ7q-mYOwoCemb5VD~bFXUBdrF1yiybaRHw-v6USbw53QZ2Qa4hfDkqgoEKwvEznBvR~sQnk5v-slX8~aJBhySS5XpkfdoE-yl8hh697xIyH~OliwrCg7h5iSkotwW9~EvTnLoVkXkuvru35eLhN4~gGMs3WDUAuucOl8JZdeg6CjAQQ~JWv6FJnb2wyvGrGJzOf70~8s08~qSqiCroyZfqUiZmw20eCIWXp4A__&Key-Pair-Id=APKAJVSE2BEPIQCCPH6Q
It seems like the original image is a TIFF file, not a JPEG. That's why you cannot see it in a browser but can open it upon download. The content type header is being sent correctly by Cloudfront if you look at the response headers.

Use S3 pre-signed url to upload object with cache-control header on responses

It seems unclear form the docs, but here is my goal:
Create a presigned url to upload a file to s3
Pass that url to the browser
The browser uploads a file selected by the user to s3 using the pre-signed url
When the object on s3 is requested, the "Cache-Control: max-age=604800" header is on the response.
I would LIKE to not have to rely on the client to do anything special to make this happen. Meaning, some signal to S3 that it should set the cache control header to that value would have to be present in the pre-signed url, but I can't tell from the docs or 50 google searches how that is accomplished.
Any illumination into how this can be accomplished would be great!

Presigned URL dont work for PUT but it works for GET S3

I'm having a trouble with Amazon S3 presigned URL. In my configuration of bucket policy I give access only to an specific IAM User, I mean, is not public. So, If I navigate in the browser to a file url of my S3 bucket, I receive an access denied message.
So, I use the aws-cli tool to generate a presigned url of that file. With that URL I'm able to get the file correctly, but the issue is when I try to put a file to the bucket. Using that url I cannot put a file beacuse I'm getting this message error:
<Code>SignatureDoesNotMatch</Code>
<Message>The request signature we calculated does not match the signature you provided. Check your key and signing method.</Message>
What I'm missing?
You'll need a different presigned URL for PUT methods and GET methods. This is because the HTTP verb (PUT, GET, etc.) is part of the "CanonicalResource" used to construct the signature. See "Authenticating Requests" in the Amazon S3 reference docs for details.

Removing response headers when accessing images from S3

Can we remove response headers when we are accessing images stored on Amazon S3?
By default it is giving the following headers:
x-amz-id-2:
x-amz-request-id:
Server:
By default it is giving amazon related values for these headers. Is there any way to remove headers?
Not without proxying the requests through some software you control that can strip the headers. Pretty sure Amazon has no user setting for that.