Modify S3 bucket response? - amazon-s3

I want to serve an HTML page from an S3 bucket, which I'm able to do w/o issue. I'd like to then have the S3 bucket response (the static webpage) include the request headers - can I do this?

Related

Dynamically override content-type response header in AWS CloudFront

I'm using AWS S3 and CloudFront to distribute content.
My files stored in S3 have binary/octet-stream type but in fact they can be images or documents.
When generating S3 URLs, I can override the response content type with a parameter like this: https://my-bucket.s3.eu-central-1.amazonaws.com/foo/bar?[...]&response-content-type=image/jpeg
Is there a way to do it with CloudFront (with the same S3 bucket as origin)?
I tried adding the same parameter -- it's ignored.
I can create a response headers policy and add a custom header overriding origin, but as far as I can see, it'll be the same for all files whereas I need to control it with a request parameter.

Cloufront should always append path for s3 bucket

I have a Cloudfront service which points to an index.html file in a S3 bucket.
Calling the Cloudfront URL is rendering the application which is correct.
I now want to use a custom "path" that gets appended to the Cloudfront.
So instead https://asdf.cloudfront.net/ I want to use https://asdf.cloudfront.net/my-app/ to point to my S3 bucket.
Is this possible with Cloudfront or do I have to move my s3 bucket content into a folder and then point to it?

Direct CloudFront to Specific Bucket Folder if Path Elements Exists

I have a CloudFront distribution in front of a S3 static website.
I want all traffic where first path element is profile to be directed to one file in my bucket.
For example, for a GET request to https://example.com/profile/12345, I want CloudFront to return S3 object s3://<bucket_name>/profile/index.html.
My goal is that I would handle dynamic content for profile/12345 using frontend JS and my API.

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!

Attach S3 bucket to URL endpoint

How can I attach an S3 bucket to an URL on my site. I tried but could not get it to work.
For instance my URL is:
mysite.com/media
And my S3 bucket should be linked directly to the above URL?
You're going to want to use CloudFront in front of S3. This will allow you to use your domain and serve content from S3.
Check out Using CloudFront with Amazon S3 for details on how to do it.