R
Railway•5mo ago
sara!khan

everytime i deploy my image file that i was uploaded is missing

i use filesystem to save my all images. But when i deploy again my file is gone all of the product i have upload is left me just only text.. I think because of the old one would be delete after new deploy And how should i handle this ? Use another file system ?
12 Replies
Percy
Percy•5mo ago
Project ID: b84d9bbc-534d-4917-ae24-79121d6fb78b
sara!khan
sara!khan•5mo ago
b84d9bbc-534d-4917-ae24-79121d6fb78b
Fragly
Fragly•5mo ago
The files in your deployment is ephemeral, so it's not possible to store persistent files that way to store persistent files on Railway, you'd want to use a volume
sara!khan
sara!khan•5mo ago
i have config mount volume in railway setting and fill more 2 varibles follow the docs and try with upload new image size 3Mb and go back to check size in volume's metric from my setting in project is when i have upload the file it will upload to 'media' folder and i config in payload volume path is '/media' is i correctness config ?
sara!khan
sara!khan•5mo ago
this is my config
No description
Fragly
Fragly•5mo ago
Yea, keep in mind though that the /media folder is not in your app's root by default I recommend you use RAILWAY_VOLUME_MOUNT_PATH service variable to get the path of your /media folder
sara!khan
sara!khan•5mo ago
i try all day but still the same with it unmount sir. when i try to redeploy all the file is gone again
No description
sara!khan
sara!khan•5mo ago
i try first with '/media' because all the file will save in media folder second i try with '/app/media' still same result third i try with '/app' deploy was crashed
Fragly
Fragly•5mo ago
nah nah, Railway provides the RAILWAY_VOLUME_MOUNT_PATH themselves, you're not supposed to write that into service variables
sara!khan
sara!khan•5mo ago
okay one last question ;-;) in my code i executed code to save upload files to folder 'media' and i mount in railway to '/app/media' it didn't mean these two directory will sync together when i redeploy and didn't mean the file i have upload will save in mount volume correct right ? --- sorry for my bad english, i try so hard to understand both of english and railway sir
Fragly
Fragly•5mo ago
No problem at all 🙂 If you write a file to RAILWAY_VOLUME_MOUNT_PATH then it'll store that file in your Volume, this Volume is attached to the docker container when the docker container starts, the volume and its contents will remain intact until you delete it Meaning to say, anything you write to RAILWAY_VOLUME_MOUNT_PATH will stay there and your application will be able to access it, all the files will remain there unless you delete them, naturally ( by the way, i say write to RAILWAY_VOLUME_MOUNT_PATH only out of principal since it's better to the path the service variable gives than just a hardcoded path, but it should work fine the way you have it )
sara!khan
sara!khan•5mo ago
Aowwww i got it !