5 months ago
Hello Railway
i have a public file in my projects that when image uploads are done saves there. I deployed on railway, am able to upload images but they dont display. All i can see is thump img.
I also can find the public folder in railway db.
what could be the problem ?
7 Replies
5 months ago
Hey there! We've found the following might help you get unblocked faster:
🧵 Problems getting images and displaying console.log() on a Railway deployment
🧵 Problemas al obtener imágenes y mostrar console.log() en un deploy de Railway
If you find the answer from one of these, please let us know by solving the thread!
5 months ago
This thread has been marked as public for community involvement, as it does not contain any sensitive or personal information. Any further activity in this thread will be visible to everyone.
Status changed to Open brody • 5 months ago
5 months ago
what's the stack? if you are using docker, did you copy the public folder?
fra
what's the stack? if you are using docker, did you copy the public folder?
5 months ago
nestjs+prisma+mysql
Yes am using docker and i didnt copy the public folder.
How can i add it please ?
5 months ago
can you post your dockerfile?
in nextjs you would do something like:
COPY --from=installer /app/public ./publicbut it depends how did you build your image
5 months ago
the Docker am taking about is that of railway.
i didnt use a third party to manage file upload. i did a custom file upload
5 months ago
how do you upload the images? usually you use services like S3/ R2/ etc...and then you use the url pointing to the image, can you share a screenshot of the network tab for the image that are failing? maybe you need to update the cors for the bucket you are using?
5 months ago
I am not sure about your exact case, but from my understanding, you are uploading an image to your server folder and want to make it publicly accessible.
If that is the case, then yes, it is possible.
I have implemented a similar approach for handling temporary files in some of my servers using NestJS.
Here is how I did it:
I created a
tempfolder and added a.gitkeepfile inside it so that the folder is tracked but remains empty in Git.In
app.module.ts(ormain.module.ts), I imported the following:
ServeStaticModule.forRoot({
rootPath: join(__dirname, '..', 'src/assets/temp-files'),
}),
I used
fs(import fs from 'fs') to save and read files.For public APIs, based on the route/path, you can read the file and return it in the response.
I hope this helps you.