Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to convert network pictures into base64 in NodeJS

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/02 Report--

It is believed that many inexperienced people don't know what to do about how to convert web pictures into base64 in NodeJS. Therefore, this paper summarizes the causes and solutions of the problem. Through this article, I hope you can solve this problem.

The code is as follows:

Var http = require ('http'); var url =' http://thirdwx.qlogo.cn/mmopen/BEMV4WOAicktAAllnv9FdJFSU7QYVibMU62ctg7Ie5HiaCuDVCyiapibwrs48N97yrzLel03FvOUqAHEZGfBY5tCdnuHKEg4YvZSC/132'; / / A network picture http.get (url, function (res) {var chunks = []; var size = 0; res.on ('data', function (chunk) {chunks.push (chunk); size + = chunk.length; / / length of accumulated buffered data}) Res.on ('end', function (err) {var data = Buffer.concat (chunks, size); var base64Img = data.toString (' base64'); console.log (`data:image/png;base64,$ {base64Img} `);}). After reading the above, have you mastered how to convert network images into base64 in NodeJS? If you want to learn more skills or want to know more about it, you are welcome to follow the industry information channel, thank you for reading!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report