a year 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
11 Replies
a year ago
Hey, please reply with N/A in here
a year ago
What you're looking for is https://docs.railway.com/guides/volumes
a year ago
If you want to follow the docs feel free to do it, for any questions just ask me here
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
a year ago
Are you using any kind of Dockerfile? If no, Railway's build system automatically mounts your app under /app
a year ago
So in theory it should be /app/dist/public/images or /app/public/images, depends on how your app is setup
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
Sorry, one more question — is there an option to download the data stored in a volume?
a year 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
Status changed to Solved chandrika • 12 months ago