Member-only story

Symfony: Static Files in AWS S3 with a Heroku Dyno

Luís Nóbrega
5 min readSep 15, 2018

--

Today I’m going to explain why we need to use a static storage server, external to our Heroku Dyno (app containers) to have static files in our application. And also, what are the steps needed to accomplish that.

Heroku offices

Let’s imagine that we have a file upload functionality in our application. We can receive the uploaded file, and then move it to a public folder of images, right? No. With Heroku, this is not recommended.

Is because all files existing in the application, other than those included in the deploy, are regularly deleted.

Heroku has an ephemeral file system where the dyno is restarted once a day by erasing everything else, other than what wasn’t deployed, and does that also at each deploy.

Note: If you want a test environment instance, then this can be a good thing, since we get a clean application regularly or at each deploy.

Therefore, it is necessary to find a way to store files externally to the dyno.

Why S3?

S3 is a cloud computing web service offered by Amazon Web Services. It provides storage of objects through web services interfaces.

It was launched in 2007 by Amazon, his fifth Web Service available to the public.

--

--

Luís Nóbrega
Luís Nóbrega

Written by Luís Nóbrega

Web Developer at 25friday. Likes to travel, write and being a father.

Responses (1)