form-data/form-data

How do I get upload progress when I submit???

Jane-blog opened this issue · 1 comments

const formData = new NewFormData()
formData.submit(options,(err, res) => { })
Use node to obtain the file data flow from the specified local path and upload it to the service. During this process, obtain the upload progress

const formData = new FormData();
formData.append('file', fc);
formData.append('fileInfo', JSON.stringify(fileInfo));
const req = formData.submit(uploadUrl);
req.on('socket', () => req?.socket?.on('drain', () => {
if (req && req.socket) {
let percent = +((req.socket.bytesWritten / fileInfo.fileSize)).toFixed(2);
}
}))