The problem of how to send post by buffer in Node.js

send the buffer to the backend through the http.request in Node.js. How can the server get these datanies?

function  doapost(data,i) {
    return new Promise(function (resolve,reject) {
        let contents = data
        data = null;
        let options = {
            host: "localhost",
            path: "/nodepost/",
            port: 8000,
            method: "POST",
            headers: {
                "Content-Type": "application/x-www-form-urlencoded",
                "Content-Length": contents.length
            }
        };
        let req = http.request(options, function (res) {
            console.log(""+i+"")
            res.on("data", function (chunk) {
                console.log(chunk.toString());
            });
            res.on("end", function (d) {
                resolve("end");
            });
            res.on("error", function (e) {
                reject(e);
            })
        });
        req.write(contents);
        req.end();

    })
}

where data is buffer type data, above is sending data playback, and the backend receiver is Django, code as follows:

def nodepost(request):
    username=request.POST["username"]
    chunks = dict(
        data=bson.binary.Binary(bytes(request.POST["data"])),
        n=request.POST["n"],
        file_id=request.POST["file_id"],
        username=username,
        length=request.POST["length"]
    )
    client = pymongo.MongoClient("localhost", 27017)
    db = client.cloudfiledb
    db[username + "filedata"].insert(chunks);
    return HttpResponse(chunks["username"])

the above code is the back-end processing code that I used to convert data of buffer type to string and send it to the backend through JSON.stiringify. Now, I would like to ask all code friends, if you send data of type buffer directly, how should the backend get the data sent?

Mar.09,2021
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-1b38c4f-2c158.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-1b38c4f-2c158.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?