Question:
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
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
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:
1 2 3 4 5 6 7 8 9 10 11 |
This XML file does not appear to have any style information associated with it. The document tree is shown below. NoSuchKey hk3+d+***********************************************************+EO2CZmo= |
Answer:
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.