How To Extend Duration Of Amazon S3 Signed Link In Elixir Arc — Tentamen Software Testing Blog

TL;DR

This post explains how to change default Elixir Arc S3 Signed Link expiration time.

Elixir Arc

Elixir Arc is a valuable Elixir library that enables developers to store files to Amazon S3 buckets from a Web application. In Arc Github readme page, there is documentation on how to create a signed URL:

# To generate a signed url:
Avatar.url({“selfie.png”, user}, :thumb, signed: true)

Signed URL is publically available, but hard to guess URL, something like this:

Link expiration parameter is where 300 is default Arc value in seconds. How to change that value? An important thing with Open Source Elixir is that readable code is publically available. We searched Arc Github repo for the word and we found this line:

https://github.com/stavro/arc/blob/b67649c88a0bfefa568db0b2e7f9c203eef83d8d/lib/arc/storage/s3.ex#L78

Which gives us the following code for setting sign expiration time:

Avatar.url({“selfie.png”, user}, :thumb, [signed: true, expires_in: 36_000])

With this, we set the expiration time to ten hours.

Originally published at https://blog.tentamen.eu on August 31, 2020.

Founder of Tentamen, software testing agency.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store