R
Railwayβ€’9mo ago
Nyll

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.
No description
18 Replies
Percy
Percyβ€’9mo ago
Project ID: 41f51fc1-84d3-4ccd-ab23-b14b095922f5
Brody
Brodyβ€’9mo ago
can you share you repo so we could better understand the file structure of your app
Nyll
Nyllβ€’9mo ago
unfortunately this repo is private for a client but the most important parts of it is basically this /projectName |- /public |- /userFiles
Brody
Brodyβ€’9mo ago
thats really not much to go off of
Nyll
Nyllβ€’9mo ago
what sort of information that I could provide for a better idea of the project?
Brody
Brodyβ€’9mo ago
full structure
Nyll
Nyllβ€’9mo ago
No description
Brody
Brodyβ€’9mo ago
does your app upload files into the userFiles folder?
Nyll
Nyllβ€’9mo ago
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
Brody
Brodyβ€’9mo ago
what is the root directory set to on the service?
Nyll
Nyllβ€’9mo ago
basically the file structure above is the repo and in the service the root is itself /
No description
Brody
Brodyβ€’9mo ago
then the mount would likely be /app/public/userFiles
Nyll
Nyllβ€’9mo ago
I will test it now update on the solution, each time the project redeploys the files disappear again.
Brody
Brodyβ€’9mo ago
what is your volume's mount path
Dmitry
Dmitryβ€’9mo ago
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)
Nyll
Nyllβ€’9mo ago
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:
// Stream the file data efficiently
const stream = fs.createReadStream(filePath)
stream.pipe(event.node.res)
// Stream the file data efficiently
const stream = fs.createReadStream(filePath)
stream.pipe(event.node.res)
Nyll
Nyllβ€’9mo ago
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.
Dmitry
Dmitryβ€’9mo ago
Got it πŸ™‚ Yeah I don't think the public folder is meant for that use case tho πŸ˜„ Glad you sorted it out tho
Want results from more Discord servers?
Add your server