How to Generate a Presigned S3 URL via AWS CLI

前端 未结 5 1361
误落风尘
误落风尘 2021-02-01 04:15

Is there a way to create presigned URL for objects in S3 bucket using AWS CLI?

I know that could be done using SDK, but is it possible with CLI?

I found this on

5条回答
  •  死守一世寂寞
    2021-02-01 05:01

    Did you try aws s3 presign?

    Generate a pre-signed URL for an Amazon S3 object. This allows anyone who receives the pre-signed URL to retrieve the S3 object with an HTTP GET request. For sigv4 requests the region needs to be configured explicitly.

    This will generate a URL that will expire in 3600 seconds (default)

    aws s3 presign s3://mybucket/myobject
    

    This will generate a URL that will expire in 300 seconds

    aws s3 presign s3://mybucket/myobject  --expires-in 300
    

    Output

    https://mybucket.s3.amazonaws.com/myobject?AWSAccessKeyId=AKIAJXXXXXXXXXXXXXXX&Expires=1503602631&Signature=ibOGfAovnhIF13DALdAgsdtg2s%3D
    

提交回复
热议问题