Using Amazon s3 boto library, how can I get the URL of a saved key?

前端 未结 3 954
执笔经年
执笔经年 2021-01-30 10:19

I am saving a key to a bucket with:

    key = bucket.new_key(fileName)
    key.set_contents_from_string(base64.b64decode(data))
    key.set_metadata(\'Content-Ty         


        
3条回答
  •  旧巷少年郎
    2021-01-30 11:08

    For Boto3, you need to do it the following way...

    import boto3
    
    s3 = boto3.client('s3')
    url = '{}/{}/{}'.format(s3.meta.endpoint_url, bucket, key)
    

提交回复
热议问题