R
Railway8mo ago
Panda

Is storing a large file into Node public folder possible?

I'd have an api that loads the file from a google bucket and stores it into the public folder. I'd like to do this because I need to use these big images all the time and they aren't changing at all, but I can't upload them to Github. I'd like to read them with like fs.readFile(...), so it's quicker read time I tried just using them from the bucket but each read takes like 4 hours, so it's not really feasible.
18 Replies
Percy
Percy8mo ago
Project ID: N/A
Brody
Brody8mo ago
how large are these images?
Panda
Panda8mo ago
1 gb it's just one file at the moment, but might be more in the future
Brody
Brody8mo ago
how often would the image change?
Panda
Panda8mo ago
never I just need to have it like in the cache so i can read it locally I guess
Brody
Brody8mo ago
you could upload it to a volume and read it from the volume?
Panda
Panda8mo ago
uhh, would that mean faster read time?
Brody
Brody8mo ago
than from google, yeah for sure
Panda
Panda8mo ago
alright I'll try it out, thanks I didn't know about those
Brody
Brody8mo ago
want a walk through it?
Panda
Panda8mo ago
I'll try it myself, if I get stuck I'll let you know ^^ thanks for your help, I appreciate you
Brody
Brody8mo ago
alright!
Panda
Panda8mo ago
Hey so just a quick question about this. I managed to store the image to the volume, and I'm trying to access it inside of puppeteer (im using it to generate pictures). I'm trying to acces it like this ${process.env.RAILWAY_VOLUME_MOUNT_PATH}/StarrySky.png I'm sure it exists because I can list all the files from that mount path. But when done through an image tag it doesn't load at all. Should I be loading the file into memory and passing it as a base64 string for this use case?
<img src="<%= starrySkyUrl %>" />
<img src="<%= starrySkyUrl %>" />
yeah that works, sorry for pinging
Brody
Brody8mo ago
I assume you need to load the file into memory to do some kind of processing on it right? otherwise you don't want 1gb sitting around in memory because that's expensive
Panda
Panda8mo ago
I just need to load it into the puppeteer to screenshot it, then it gets thrown away again lol
Want results from more Discord servers?
Add your server