Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Amazon S3 Url rewrite [closed]

How can I change the Amazon S3 url from http://bucket.amazons3.com/imagepath.jpg to http://image.mydomain.com/imagepath.jpg

EDIT: Basically the whole reason for this is to hide the amazon s3 url from my users.

I was thinking about a HttpModule that would redirect the request from image.mydomain.com to bucket.amazons3.com. But that would require all requests to be handled by my servers first then forwarded.

like image 317
Arron S Avatar asked Feb 20 '09 19:02

Arron S


People also ask

How long is S3 Presigned URL valid for?

In the Amazon S3 console, the maximum expiration time for a presigned URL is 12 hours from the time of creation.

Why is my S3 URL Access Denied?

If you're trying to host a static website using Amazon S3, but you're getting an Access Denied error, check the following requirements: Objects in the bucket must be publicly accessible. S3 bucket policy must allow access to the s3:GetObject action. The AWS account that owns the bucket must also own the object.

Does S3 bucket need to be public for Presigned URL?

All objects and buckets are private by default. However, you can use a presigned URL to optionally share objects or allow your customers/users to upload objects to buckets without AWS security credentials or permissions.

Why should you use S3 Presigned URLs?

The main purpose of presigned URLs is to grant a user temporary access to an S3 object. However, presigned URLs can be used to grant permission to perform additional operations on S3 buckets and objects.


2 Answers

If I understand, you need to specify your domain name instead of S3. To do this, you need to write a handler which will act as a proxy to the amazon server.

But, that would actually double your bandwidth as you need to send the image to the client as well fetch the image for S3.

I am not sure is there any S3 specific way to handle this.

Below is Amazon S3 specific way taken from Amazon S3, CNAME record

The average user may sign up for Amazon S3 hosting and begin uploading files - accepting the default URL structure for hosted files:

http://s3.amazonaws.com/your-bucket/some-file.txt If you plan on using S3 to host media files - more specifically Flash files - you’ll run into Adobe’s cross domain security policy. The fix requires mapping your hosted S3 files to look as though they are being served from your own domain - virtual hosting. The easiest and most attractive method would be a hosted file URL that like this:

http://s3.your-site.com/some-file.txt To get started, create a bucket on S3 that you want as the root for your hosted files. For this example, your S3 bucket would be:

s3.your-site.com The most important step is adding the appropriate CNAME record to your DNS settings.

Name Type Data s3.your-site.com CNAME s3.amazonaws.com. Expect your new DNS settings to take up to 24-48 hours to resolve.

like image 171
Ramesh Avatar answered Oct 12 '22 22:10

Ramesh


Creating a CNAME on s3.amazonaws.com. is sufficient. There is no need to prepend the bucket name.

like image 25
Vincent Avatar answered Oct 12 '22 22:10

Vincent