简体   繁体   中英

Multiparty read uploaded file content

How can I get uploaded file content using multiparty in node.js? I don't need temp file, I need to redirect all stream into Google Cloud Storage in order to save the file content, but I can't find the way to get this content with events.

Found the answer. We need to use part stream a subscribe to standard streams events, like, data and end in order to receive file's data.

part.on("data", chunk => {
    writeStream.write(chunk);
});

part.on("end", chunk => {
    writeStream.end(chunk);
});

writeStream - is a another stream where you want to put your data. In my case that was Google Cloud Storage file PUT request via signedUrl. part - is a part object of a form part event

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