3

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?

Michael
  • 3,206
  • 5
  • 26
  • 44
  • The fact that they are encoded doesn't mean that are not special chars. if you use those chars in your key that's normal. The solution is not to us chars which need encoding while used in URL – MatPag Jan 13 '18 at 15:35
  • Agree with Mat . @Michael have a look into [This discussion](https://stackoverflow.com/questions/7116450/what-are-valid-s3-key-names-that-can-be-accessed-via-the-s3-rest-api) if you already haven't. – ADM Jan 13 '18 at 15:39
  • @ADM i've added a proper answer to this, BTW in your link there is the same thing. Probably this question should be closed as duplicate – MatPag Jan 13 '18 at 15:41
  • Possible duplicate of [What are valid S3 key names that can be accessed via the S3 rest API?](https://stackoverflow.com/questions/7116450/what-are-valid-s3-key-names-that-can-be-accessed-via-the-s3-rest-api) – MatPag Jan 13 '18 at 15:45

2 Answers2

2

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

MatPag
  • 41,742
  • 14
  • 105
  • 114
2

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.