I'm trying to generate a presigned url to a S3 folder (which itself contains more folders/files) and distribute it between my clients so they can download its content. i.e. by clicking the link, the users will download the folder to their local disk.
However, I keep getting a "no such key" error in an XML dialogue.
I'm using client.generate_presigned_url() from boto3 sdk
def create_presigned_url(bucket, object):
try:
url = s3_client.generate_presigned_url(
'get_object',
Params={
'Bucket': bucket,
'Key': object
},
ExpiresIn=240,
HttpMethod='GET'
)
except ClientError as e:
print(e)
return None
return url
this is the error message:
This XML file does not appear to have any style information associated with it. The document tree is shown below.
<Error>
<Code>NoSuchKey</Code>
<Message>The specified key does not exist.</Message>
<Key>output/BARNES/070419/APR19BAR/</Key>
<RequestId>E6BE736FE945FA22</RequestId>
<HostId>
hk3+d+***********************************************************+EO2CZmo=
</HostId>
</Error>
http://s3tools.org/s3cmd works pretty well and support the s3:// form of the URL structure you want. It does the business on Linux and Windows. If you need a native API to call from within a python program then http://code.google.com/p/boto/ is a better choice.
Get an S3 Object's URL # Navigate to the AWS S3 console and click on your bucket's name. Use the search input to find the object if necessary. Click on the checkbox next to the object's name. Click on the Copy URL button.
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.
A user who does not have AWS credentials or permission to access an S3 object can be granted temporary access by using a presigned URL. A presigned URL is generated by an AWS user who has access to the object. The generated URL is then given to the unauthorized user.
S3 has no concept of "folders". What you are effectively trying to do here is create a presigned url for multiple keys which is also not possible. If you absolutely have to share single url for multiple files, you'll need zip them into a single object and then share key of that object using presigned url.
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