Michael
Michael

Reputation: 3356

Special characters is S3 key name of uploaded file

Background

I'm using aws-android-sdk to send files from Android app to S3. The filename contains specials character such as =.

To do that, I use TransferUtility.upload(...) as explained in this guide.

The problem

When passing a key containing special characters such as =, the key is being URL encoded.

For example, the key:

year=2018/month=1/versions=1,2/my_file.txt

Becomes:

year%253D2018/month%253D1/versions%253D1%252C2/my_file.txt

My question

How can I upload an S3 file from my Android application, while using special characters in it's key?

Upvotes: 3

Views: 14152

Answers (2)

Ashot Tonoyan
Ashot Tonoyan

Reputation: 59

If you are partitioning your data on S3, it's a common practice to use = sign in the S3 key. Also interesting to note that the AWS SDK for iOS does not automatically encode the S3 keys.

Upvotes: 2

MatPag
MatPag

Reputation: 44813

The problem is that you are not following the key name convention described in this paragraph called Object Key Guidelines of Amazon S3.

Summary from the link:

The following character sets are generally safe for use in key names:

Alphanumeric characters [0-9a-zA-Z]
Special characters !, -, _, ., *, ', (, and )

The following are examples of valid object key names:

4my-organization
my.great_photos-2014/jan/myvacation.jpg
videos/2014/birthday/video1.wmv

Remove those special chars from the URL following the guideline and the problem will disappear

Upvotes: 1

Related Questions