divinedragon
divinedragon

Reputation: 5346

Unwanted extra characters in S3 Key while uploading files for aws cli

I have my following shell script which I am using to upload files to my s3 bucket.

#!/bin/sh

export AWS_ACCESS_KEY_ID="$KEY_ID"
export AWS_SECRET_ACCESS_KEY="$KEY_SECRET"

echo "[INFO] AWS_ACCESS_KEY_ID - $AWS_ACCESS_KEY_ID"
echo "[INFO] AWS_SECRET_ACCESS_KEY - $AWS_SECRET_ACCESS_KEY"

S3_URL="s3://mybucket/uploads"

aws s3 cp ../data.pdf       $S3_URL/data.pdf
aws s3 cp ../data.html.zip  $S3_URL/data.html.zip

echo "[INFO] Uploaded Successfully"
echo ""

When I run this script, the files get uploaded to S3 bucket. However, I see some extra characters at the end of the key name.

Here is the screenshot from my S3 browser UI,

enter image description here

Can somebody tell me why these characters are coming up automatically, when I didnt intend them to come.

How can I get rid of these?

Also, this is creating issues for my download service which is not able to read these files and gets Key not found error.

Upvotes: 0

Views: 873

Answers (1)

John Rotenstein
John Rotenstein

Reputation: 269320

It appears that you have some invisible UTF-8 code inserted in your script.

See: Wordpress putting %E2%80%8E at the end of my url, howcome?

Also, see web search: https://www.google.com.au/search?q=%25e2%2580%258b

Make sure that you are using a real text editor (not something like MS Word). There should be something like a Zap Gremlins command that can remove bad characters.

Or, just delete and re-type (don't copy/paste) the lines with aws s3 cp in them.

Upvotes: 1

Related Questions