sandrkosh
sandrkosh

Reputation: 13

How do I get an image to postman using Express.js?

I have some jpeg and png photos in my local machine. How do i show them on my postman using express.js?

Do I use sendFile?

And is it possible to print more than one photo?

Here is a template

app = require("express")();

app.get("/", (req, res) => {

res.send("I want to send the image here")

})

Same Question as How do I get image/file data on postman using get method?

Upvotes: 1

Views: 786

Answers (1)

eol
eol

Reputation: 24565

One simple way to do this is to serve the files statically by using express static middleware.

Assuming your images reside in a uploads folder in your app's root, you'd simply add to your express app:

app.use("/uploads", express.static('uploads'))

You can then request it through postman/browser with GET http://your-host/uploads/name-of-image.png.

Upvotes: 1

Related Questions