简体   繁体   中英

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?

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 .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM