Always set validity duration of presigned URLs with AWS S3 SDK

I was using Drive module of AdonisJS to generate a presigned URL for a document, without configuring when the document would expire – I was assuming that the default behavior would be to generate a URL that never expires. It appeared that the presigned URL was expiring 15 minutes after its generation.

Drive module is using getSignedUrl function from AWS S3 JavaScript SDK, which defaults to a validity of 15 minutes.

It’s necessary to set a validity duration suitable for your project. This is how to do it with Drive module of AdonisJS:

const presignedUrl = await Drive.getSignedUrl(path, {
expiresIn: '6 hours',

Join my mailing list

Get monthly insights, personal stories, and in-depth information about what I find helpful in web development as a freelancer.

Email advice once a month + Free XState report + Free course on XState

Want to see what it looks like? View the previous issues.

I value your privacy and will never share your email address.