Skip to main content

How do you build URLs pointing to objects in an S3 bucket?

You only need to build expiring urls if you want to restrict access.

Here's some code to generate the signed url which expires in 3 mins.

using (var s3Client = AWSClientFactory.CreateAmazonS3Client("MyAccessKey", "MySecretKey"))
{
    GetPreSignedUrlRequest request = new GetPreSignedUrlRequest()
        .WithBucketName("MyBucketName")
        .WithKey("MyFileKey")
        .WithProtocol(Protocol.HTTP)
        .WithExpires(DateTime.Now.AddMinutes(3));

    string url = s3Client.GetPreSignedURL(request);
}

Hello, my name is Lee and I work as a full-stack web developer specialising in Microsoft ASP.NET technologies. I love using Umbraco and also MANAGED, my own application management software.

Contact me at lee.gunn@secretorange.co.uk

All skills

Contact

Get in touch to talk about your project or just ask me a question.

lee.gunn@secretorange.co.uk