How to Persist multer uploads using Railway’s non-ephemeral storage?
aridstudio
PROOP

10 months ago

I’m using Railway to host an Express.js API, and I'm handling image uploads using multer. The images are saved in the folder dist/public/images.

The problem I’m facing is that every time I redeploy the project, all uploaded images are deleted.

I’ve read that Railway supports non-ephemeral storage, but I couldn't find a clear guide on how to configure or use it properly in a project.

Could you help me understand how to set up persistent storage so that user-uploaded files are not lost after each deploy?

I’d like to keep storing them in a folder like public/images, accessible via HTTP.

Thanks in advance!

Best regards,
Bastián Fuentes

Solved$10 Bounty

11 Replies

10 months ago

Hey, please reply with N/A in here


aridstudio
PROOP

10 months ago

empathetic-charisma


10 months ago

What you're looking for is https://docs.railway.com/guides/volumes


10 months ago

If you want to follow the docs feel free to do it, for any questions just ask me here


aridstudio
PROOP

10 months ago

Thanks for the quick reply!

I actually followed the Volumes documentation, but I’m still having trouble making it work as expected.

I created a volume and tried to mount it to the dist/public/images folder where my uploaded images are stored. However, after each deploy, the images still get deleted — so I’m probably not linking the volume correctly.

Could you help me understand the proper way to bind the volume to dist/public/images, or let me know if I'm missing something important?

Thanks again!

Best regards,
Bastián Fuentes


10 months ago

Are you using any kind of Dockerfile? If no, Railway's build system automatically mounts your app under /app


10 months ago

So in theory it should be /app/dist/public/images or /app/public/images, depends on how your app is setup


aridstudio
PROOP

10 months ago

Just wanted to say thank you — it worked!

I was able to properly link the volume to dist/public/images, and now the uploaded images persist after deployments.

Really appreciate the support!

Best regards,
Bastián Fuentes


aridstudio
PROOP

10 months ago

Sorry, one more question — is there an option to download the data stored in a volume?


10 months ago

Not through Railway's dashboard, you have two options:

  • Detach your volume from your service and then attach it to a Volume Browser template

  • Create an authenticated endpoint on your service to retrieve files on your volume


aridstudio
PROOP

10 months ago

Thank you sir!


Status changed to Solved chandrika 10 months ago


Loading...