Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Amazon S3 URL Encoding

If I have a file name that is

a'd1 & "[tttt]" + 'sq.jpg

When this gets uploaded to Amazon S3, it gets converted to this

a'd1 & %22[tttt]%22 + 'sq.jpg

So the double quotes are URL encoded and the filename itself is changed.

The file has to be fetched using the encoded URL

a%27d1+%26+%2522%5Btttt%5D%2522+%2B+%27sq.jpg So the encoding rules seem to be:

": %2522  (double encoded)
Space: + 
&: %26 
[: %5B
]: %5D
+: %2B 

Is there a way to determine all the rules that S3 requires? Normal javascript encoding with (encodeURI or even encodeURIComponent) won't work

like image 376
sat Avatar asked Jan 11 '14 19:01

sat


People also ask

What URL format do Amazon S3 buckets end in?

An S3 bucket can be accessed through its URL. The URL format of a bucket is either of two options: http://s3.amazonaws.com/[bucket_name]/ http://[bucket_name].s3.amazonaws.com/

How do I encode a Presigned URL?

Generating pre-signed URL using : var params = { Bucket: bucket, Expires: Settings. UrlGetTimeout, Key: record }; S3. getSignedUrl('getObject', params);

Is S3 URL case sensitive?

You can utilize the Amazon S3 storage service for storing your website files even though the website is hosted on-premise, on your own server. Unlike standard Windows file systems, the Amazon S3 storage is case-sensitive.

What style of URL access is available for S3 bucket?

Amazon S3 supports both virtual-hosted–style and path-style URLs to access a bucket. Because buckets can be accessed using path-style and virtual-hosted–style URLs, we recommend that you create buckets with DNS-compliant bucket names.


1 Answers

This is not from a definitive source, but it has worked for my requirements: encodeS3URI

It replaces the following characters +!"#$&'()*+,:;=?@

S3 replaces spaces in filepaths with +, so its best to do the URI encoding before any further string replacements

like image 179
amigolargo Avatar answered Sep 28 '22 07:09

amigolargo