Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
Jane-blog opened this issue Sep 6, 2023 · 1 comment
Open

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

Jane-blog opened this issue Sep 6, 2023 · 1 comment

Comments

@Jane-blog
Copy link

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

@23431
Copy link

23431 commented Jan 8, 2024

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);
}
}))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants