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?
Sign in to the AWS Management Console and open the Amazon S3 console at https://console.aws.amazon.com/s3/ . In the Buckets list, choose the name of the bucket that contains the object that you want a presigned URL for. In the Objects list, select the object that you want to create a presigned URL for.
S3 pre-signed URLs are a form of an S3 URL that temporarily grants restricted access to a single S3 object to perform a single operation — either PUT or GET — for a predefined time limit. To break it down: It is secure — the URL is signed using an AWS access key.
Pre-signed URLs can be generated for an S3 object, allowing anyone who has the URL to retrieve the S3 object with an HTTP request. Not only is this more secure due to the custom nature of the URL, but the available options also allow you to set an expiration on the URL, the default being one hour.
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"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With