R
Railway14mo ago
Petra

Writing permission

Hello! I'm new to Railway and have a question about how to change writing permission on a folder. My project is a Laravel API. I have created the folder 'uploads' in the 'public' folder. When an image is sent with POST to the API the controller moves the file to the folder 'uploads'. This works fine locally but with my API deployed to Railway I get an error message saying "Unable to write in the "/app/public/uploads" directory." How can I change the writing permission on my folder 'uploads'? Grateful for any help!
9 Replies
Percy
Percy14mo ago
Project ID: N/A
Brody
Brody14mo ago
you would want to use a volume for this https://docs.railway.app/reference/volumes mount the volume to /app/storage then you can save your files to /app/storage/uploads
Petra
PetraOP14mo ago
It didn't work. I created the volume, connected it to the service, mounted it to /app/storage and used the environment variables RAILWAY_VOLUME_NAME=storage and RAILWAY_VOLUME_MOUNT_PATH=/storage. I still get status 500 and the message "message": "Unable to write in the "/app/public/uploads" directory." Any solutions, please?
Brody
Brody14mo ago
those variables are set automatically for you, please remove them from your service variables in your code you should be saving files to /app/storage/<a subfolder of your choosing> when on railway
Petra
PetraOP14mo ago
Do I have to change this code in my Laravel controller? $image->move(public_path('uploads'), $imageName);
Brody
Brody14mo ago
^
Petra
PetraOP14mo ago
Like this? $image->move(public_path('/app/storage/uploads'), $imageName);
Brody
Brody14mo ago
I'm sorry I don't know php, I'm just telling you what needs to be done, it is your task to apply it to the language you are using
Petra
PetraOP14mo ago
Ok, thanks!
Want results from more Discord servers?
Add your server