How NodeJS sends data of type buffer

demand:

  Node.jsreadSteampostmongodb

current problem:

  createReadStreamchunkNode.jspost

the code is as follows:

/**
 * Created by Administrator on 2018/4/29.
 */
var fs = require("fs");
var http = require("http");
var queryString = require("querystring")

var filepath = "./mmp.txt";
var readSteam = fs.createReadStream(filepath);
readSteam.on("data",(chunk) => {
    console.log(chunk);
    let mydata = {"name":filepath, data: chunk};
    console.log(123)
    console.log(mydata);
    doapost(mydata);
})
function  doapost(data) {
    let contents = queryString.stringify(data);
    console.log("here");
    console.log(contents);
    let options = {
        host: "localhost",
        path: "/mytestpost/",
        port: 8000,
        method: "POST",
        headers: {
            "Content-Type": "application/x-www-form-urlencoded",
            "Content-Length": contents.length
        }
    };
    let req = http.request(options, function (res) {
        res.on("data", function (chunk) {
            console.log(chunk.toString())
        });
        res.on("end", function (d) {
            console.log("end")
        });
        res.on("error", function (e) {
            console.log(e);
        })
    });
    req.write(contents);
    req.end();
}

the running result is as follows:

clipboard.png

you can see that buffer data is lost at name=.%2Fmmp.txt&data=
during upload. How can you solve this problem?

Mar.06,2021

this is the wrong
let contents = queryString.stringify (data); for your querystring module.
serialize data of type Buffer
document says:
if the type of the attribute in the obj object is < string > | < number > | < boolean > | < string [] > | < number [] > | < boolean [] >, the value of the property will be serialized. The values of other types of properties are cast to an empty string.

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1eaec2e-21ff.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1eaec2e-21ff.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?