Hello, how to use Volume?

Hello, i need to use a Volume to store images. I need then to show the images on a website
20 Replies
Percy
Percy9mo ago
Project ID: 6a68e036-a32d-403b-872c-b546785ea48e
ZannaKonda
ZannaKonda9mo ago
i have my volume mounted to /media and i am storing the files in /media/userId/year/filename.png it seems to be saved correctly but then i cannot see it
Brody
Brody9mo ago
I assume this is django?
ZannaKonda
ZannaKonda9mo ago
Hey Brody nextjs website
Brody
Brody9mo ago
haha bad guess, django by default uses /media the paths you are giving me, they are absolute paths correct? then I would need more information than "cannot see it"
ZannaKonda
ZannaKonda9mo ago
const filename = ${userId}/${now.getFullYear()}/${now.getMonth()}/${name}; ensureDirectoryExistence(${process.env.RAILWAY_VOLUME_MOUNT_PATH}/${filename}); fs.writeFileSync(${process.env.RAILWAY_VOLUME_MOUNT_PATH}/${filename}, base64Image, { encoding: 'base64' }); this is how i save it if i point by browser to railway.app/media/............/filename.png i have a not found i think i found that by default the files are stored under app folder so the url should be railway.app/app/media.... correct?
Brody
Brody9mo ago
are you setting up your next app to serve those files at that path? railway does not serve the files for you, that's something your app has to do entirely on it's own
ZannaKonda
ZannaKonda9mo ago
how can i access the files so? nope i guess
Brody
Brody9mo ago
then you know what you need to do, setup a file server in your code
ZannaKonda
ZannaKonda9mo ago
Stack Overflow
Node.js quick file server (static files over HTTP)
Is there Node.js ready-to-use tool (installed with npm), that would help me expose folder content as file server over HTTP. Example, if I have D:\Folder\file.zip D:\Folder\file2.html D:\Folder\fo...
Brody
Brody9mo ago
I'm talking about in your existing code, that's something else entirely separate
ZannaKonda
ZannaKonda9mo ago
No description
ZannaKonda
ZannaKonda9mo ago
isn't it what i need to? too?
Brody
Brody9mo ago
I'm talking about in your existing code, that's something else entirely separate
ZannaKonda
ZannaKonda9mo ago
in the link they suggest to install (IN MY CODE) a package to expose files over http would this be enough?
Brody
Brody9mo ago
the solution with the check mark does not involve your pre-existing code it recommends something completely separate and standalone you need a solution that integrates with your next app to serve files from disk at a given path
ZannaKonda
ZannaKonda9mo ago
ok i think i got it thanks
ZannaKonda
ZannaKonda9mo ago
it should be something like this
No description
ZannaKonda
ZannaKonda9mo ago
i will try tomorrow thanks again
Brody
Brody9mo ago
that's express, but yes an in code file server would need to be setup I have seen countless next apps that serve arbitrary files from disk, so there must be something standardised for next
Want results from more Discord servers?
Add your server