Volume initializing is very confusing
I have a Nuxt 3 Full-Stack web application. I need to frequently write and read data from a folder in the app "/public/userFiles", the reason it's inside of the project is because nuxt serves the files in the public directory with the url.
The issue is that I'm not able to assign the volume to it because I have zero idea where the project is. At first I assumed it's in
projectName/public/userFiles
then I discovered Nix uses another method which is putting the app inside the /app
directory, then I tried those routes: /app/projectName/public
and /app/public
.
Nothing is working and I have zero idea where my public directory is. I need to understand the file system in the volumes.18 Replies
Project ID:
41f51fc1-84d3-4ccd-ab23-b14b095922f5
can you share you repo so we could better understand the file structure of your app
unfortunately this repo is private for a client but the most important parts of it is basically this
/projectName
|- /public
|- /userFiles
thats really not much to go off of
what sort of information that I could provide for a better idea of the project?
full structure
does your app upload files into the
userFiles
folder?yes, I want the railway deployment persist the files inside this folder so when a new update comes in the files in the folder doesn't get deleted
what is the root directory set to on the service?
basically the file structure above is the repo and in the service the root is itself
/
then the mount would likely be
/app/public/userFiles
I will test it now
update on the solution, each time the project redeploys the files disappear again.
what is your volume's mount path
Why are you saving files to
public/userFiles
? Just save the files user's upload to your Volume's mount path (i.e - /app/userFiles
for example)I have solved the issue, storing the data inside folders that are supposed to be inside the project doesn't work. When I stored the data inside the
/data/*
directory it persisted. I'm not sure if that's how it's supposed to be or if you can mount in the project but this is my experiment.
the reason was for allowing the users to have access to the files by entering this url: https://example.com/userFiles/file.png
but then I made my own file delivery method using this:
note: if someone needs to implement something like this for nuxt I'm working on a package to simplify all of this: https://github.com/nyllre/nuxt-nitro-storage
GitHub
GitHub - NyllRE/nuxt-nitro-storage
Contribute to NyllRE/nuxt-nitro-storage development by creating an account on GitHub.
Got it π Yeah I don't think the public folder is meant for that use case tho π Glad you sorted it out tho