// ppt
if (
req.files[0].mimetype === "application/vnd.openxmlformats-officedocument.presentationml.presentation" ||
req.files[0].mimetype === "application/vnd.ms-powerpoint"
) {
var form = formstream();
form.buffer("file", des_file, req.files[0].originalname.substring(0, req.files[0].originalname.lastIndexOf(".")));
var options = {
method: "POST",
host: "127.0.0.1",
port: "5000",
path: "/unoconv/pdf/",
headers: form.headers()
};
const promise = new Promise(function (resolve, reject) {
var reqs = http.request(options, function (res) {
var _data = "";
res.on("data", function (data) {
_data += data;
}).on("end", function () {
resolve(_data);
}).on("error", function (err) {
reject(err);
});
});
form.pipe(reqs);
})
promise.then(function (buffer) {
console.log(buffer, "success") // buffet
fs.writeFile("./test.pdf", buffer, function (err) {
if (err) {
console.log(err);
}
})
// pdf
}, function (err) {
console.log(err, "failure")
})
}
when you finish the conversion, save the pdf file again, but opening the file is blank. What"s the problem?