Amazon AWS S3 signed URL via Wget

mg03 picture mg03 · Dec 5, 2015 · Viewed 10.3k times · Source

I am able to create an Amazon S3 signed URL for a bucket in my account from which I can download and upload via the Amazon AWS CLI.

I have created the Amazon S3 URL as follows:

from boto.s3.connection import S3Connection
key = os.environ['aws_access_key_id']
secret = os.environ['aws_secret_access_key']
c = S3Connection(key,secret,is_secure=False)
bucket = c.get_bucket('my-bucket')
bktkey = bucket.get_key('stuff.tar.gz')
seconds=60*60*12
url2 = bktkey.generate_url(expires_in=seconds)
print '%s' %url2

Using url2 and copy pasting it in Chrome, I get stuff.tar.gz downloaded.

But when I use Wget like so

wget <whatever is in url2>

I get the following exception,

HTTP request sent, awaiting response... 403 Forbidden
2015-12-04 20:48:57 ERROR 403: Forbidden.

Why is Wget failing where Chrome and Firefox are successful in downloading using the signed Amazon S3 URL?

Answer

user3323536 picture user3323536 · Feb 2, 2016

I had the same issue. The fix is to use quotes:

wget -O test.tar.gz "https://bucket.s3.amazonaws.com/app1/10/10.2/test.tar.gz?Signature=hgbdhjJHGK&Expires=1454446963&AWSAccessKeyId=AAAAAAAAA"