Accessing uploaded files


#1

I have an application that uses multer to upload an image file and store it in the /uploads folder. I’m able to access the file to do some processing on it (pass it to external API for Optical Character Recognition) but can’t figure out how to reference the uploaded image to display. I can see the files in the /uploads folder via the console. If I upload a file manually to the assets folder then it’s easy enough to grab the url and add it to one of my html files but I’m missing how to do this with files uploaded via multer. What is the recommended way of handling this?


#2

One way to do it would be to share that directory statically through express:

app.use(express.static('uploads'));

Then you would be able to get to the files with a URL like https://<project>.glitch.me/uploads/


#3

Thanks for the quick response, Tim. That got me on the right track and it’s working well now.