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
Project ID:
6a68e036-a32d-403b-872c-b546785ea48e
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
I assume this is django?
Hey Brody
nextjs website
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"
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?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
how can i access the files so?
nope
i guess
then you know what you need to do, setup a file server in your code
https://stackoverflow.com/questions/16333790/node-js-quick-file-server-static-files-over-http you mean something like this?
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...
I'm talking about in your existing code, that's something else entirely separate
isn't it what i need to?
too?
I'm talking about in your existing code, that's something else entirely separate
in the link they suggest to install (IN MY CODE) a package to expose files over http
would this be enough?
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
ok i think i got it thanks
it should be something like this
i will try tomorrow
thanks again
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