How to generate url from boto3 in amazon web services

后端 未结 1 617
-上瘾入骨i
-上瘾入骨i 2020-12-05 06:48

I have a Bucket in s3 and I am trying to pull the url of the image that is in there.

I am using boto3 and boto3 doesn\'t seem to have an implemented generate url met

相关标签:
1条回答
  • 2020-12-05 07:43

    Able to get results and did not face any issues in getting the signed URL. I used the default session since my aws creds were stored locally in "~/.aws/credentials" file and my default region is set as needed ~/.aws/config

    import boto3
    s3Client = boto3.client('s3')
    s3Client.generate_presigned_url('get_object', Params = {'Bucket': 'www.mybucket.com', 'Key': 'hello.txt'}, ExpiresIn = 100)
    

    If you need to pass params for Session, import boto3.session and create custom session

    import boto3.session
    session = boto3.session.Session(region_name='eu-central-1')
    s3Client = session.client('s3')
    
    0 讨论(0)
提交回复
热议问题