AWS S3 Signed URL with long validity in C#

313 Views Asked by At

I am trying to implement long validity signed URL for AWS S3 object. Is it possible to set 100 years in per expiration policy object like below.

    public string GetPreSignedURL(string bucketName, string identifierName, string fileName)
    {
        var request = new GetPreSignedUrlRequest
        {
            BucketName = bucketName,
            Key = this.GetObjectKey(identifierName, fileName),
            Expires = DateTime.Now.AddYears(100)
        };

        return this.awsS3Client.GetPreSignedURL(request);
    }

If not, kindly provide some reference to implement it.

1

There are 1 best solutions below

3
gshpychka On

From the docs:

Expiration time for presigned URLs

A presigned URL remains valid for the period of time specified when the URL is generated. If you create a presigned URL with the Amazon S3 console, the expiration time can be set between 1 minute and 12 hours. If you use the AWS CLI or AWS SDKs, the expiration time can be set as high as 7 days.

If you created a presigned URL by using a temporary token, then the URL expires when the token expires, even if you created the URL with a later expiration time.