简体   繁体   中英

How do I send a multipart response in expressjs?

I have an app that displays a list of pictures with titles and descriptions. The app sends a get request to the node server, and I want it to respond with the pictures and the titles/descriptions. In order to send the images at the same time as the other stuff, I think I need to use the multipart/form-data Content-Type. How do I do that? The expressjs docs don't say anything about multipart responses as far as I can tell.

In your case I would send only an initial response with image urls and then generate <img src="image.url"> in the front end.

You don't need multipart here because there will be two separate requests, one for the image metadata, and another when the browser displays the image (downloads the file).

Nevertheless I commented a use case example in which multipart responses seems to be the only way around, and currently cannot find a solution for that one, so thanks for asking.

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