aws-amplify / aws-sdk-ios

AWS SDK for iOS. For more information, see our web site:
https://aws-amplify.github.io/docs
Other
1.68k stars 886 forks source link

MIME-encoded user-defined metadata with AWSS3GetPreSignedURLRequest #241

Closed svyatoslav-zubrin closed 9 years ago

svyatoslav-zubrin commented 9 years ago

In my app I'm uploading media file to s3 bucket with custom userd-defined metadata using AWSS3GetPreSignedURLRequest. If I use simple string for metadata value - all goes well, but if I try to set some other long string with double quotes in it - the uploaded metadata appears to be initially splitted into couple of parts and than every that part seems to be MIME-encoded. I can see that in properties of the mediafile in AWS console or in my app after downloading it (with preSignedURLRequest again). I'm using AWS iOS SDK v.2.2.4. The string for custom metadata value is:

Congratulations!  You just completed the “Workout”.  Make sure you drink some water, rest your voice, and review your lesson in your vocal journal.  Make comments about how you felt, the circumstances of your workout, and anything you think you did poorly or well.  Be sure to come back tomorrow for another workout!  Practicing on a daily basis is key to growth.

Pay attention on quotes around word Workout. It seems that they are causing that issue.
And here is how the result metadata looks like (taken from AWS console):

=?UTF-8?Q?Workout_Completed:_Congratulations!__You_just_comp?= =?UTF-8?Q?leted_the_=E2=80=9CFinding_Vocal_?= =?UTF-8?Q?Freedom_Workout=E2=80=9D.__Make_su?= =?UTF-8?Q?re_you_drink_some_water,_rest_your_voice,_and_revi?= =?UTF-8?Q?ew_your_lesson_in_your_vocal_journal.__Make_comment?= =?UTF-8?Q?s_about_how_you_felt,_the_circumstances_of_your_wo?= =?UTF-8?Q?rkout,_and_anything_you_think_you_did_poorly_or_wel?= =?UTF-8?Q?l.__Be_sure_to_come_back_tomorrow_for_another_work?= =?UTF-8?Q?out!__Practicing_on_a_daily_basis_is_key_to_growth.?=
svyatoslav-zubrin commented 9 years ago

I've just updated the SDK to the latest version (2.2.5) and the issue can be reproduced as well.

ghost commented 9 years ago

Hi @svyatoslav-zubrin

According to S3 Doc: "Amazon S3 stores user-defined metadata in lowercase. Each name, value pair must conform to US-ASCII when using REST and UTF-8 when using SOAP or browser-based uploads via POST."

In your metadata value, the is not a valid ASCII characters, thus not supported by S3 since the AWS Mobile SDK for iOS are using REST to make the call. My suggestion would be change from to " in your metadata value.

svyatoslav-zubrin commented 9 years ago

Yep, my mistake. Thank you for the explanation.