Files / pictures deleted after a new deploy
Let me explain my problem
When my API ( nodejs ) is deployed online, from my front end I can add images that will be saved on the server with MULTER / FS. The problem is that if I publish code again on github railway, my api will be redeployed and I'll lose the images I've inserted. (when the api is online )
If anyone has already encountered this problem
Thanks
20 Replies
Project ID:
6fbd9afc-0438-4412-8618-6d138eec245b
project ID : 6fbd9afc-0438-4412-8618-6d138eec245b
container storage is not persistent so this is completely to be expected, of you want files to persist you must use a volume
oh ok there is an example ?
I have an example that uses node, express and busboy instead of multer, would that use useful?
yes π
it's super basic, just has some endpoints for uploading, reading, listing files, deleting files, and serving the files
just what I need
https://github.com/brody192/busboy-file-uploads
if you have any questions about the code, feel free to ask
Thank you π
nothing is commented since this was just a quick thing I threw together, it doesn't use any of the best practices like file size validation, good name sanitization, etc
no worries, I'll try to adapt it with multer and if not, I'll switch to busboy.
when running locally it will save files to
./files
in your project folder
when running on railway it will automatically use the volume
I should probably whip up a multer example too now that I think about it, you aren't the first one to come to help and use multeri have to add the same name to my volume of not necessary ?
it doesn't matter where you mount the volume, the code will automatically pick up the mount point, but personally I like to mount it to
/data
Okay, I'll give it a try and if I have any questions I'll get back to you
not much has changed
https://github.com/brody192/multer-file-uploads
Regarding the railwayVolumeMountPath in my .env I just have to add = '/data '?
no thats added automatically for you by railway
oh ok π