fix: fix uploading percent

This commit is contained in:
Andrey Ponomarenko 2020-09-25 12:54:24 +03:00
parent ea9c7c3f9b
commit 32e92f8a24
2 changed files with 3 additions and 3 deletions

View File

@ -29,8 +29,8 @@ export const rawUpload = async (params: ApiUploadProps, options: UploadOptions =
let bytesWritten = 0;
fileStream.on('data', (chunk) => {
bytesWritten += chunk.length;
const progressPercent = Number(((bytesWritten / fileSize) * 100).toFixed(0));
onUploadProgress({ progressPercent, bytesWritten, fileSize });
const progressPercent = Number(((bytesWritten / fileSize) * 100).toFixed(2));
onUploadProgress(progressPercent, { bytesWritten, fileSize });
});
const data = await request({

View File

@ -13,7 +13,7 @@ export interface ApiUploadProps {
}
export interface UploadOptions {
onUploadProgress?: (args: { progressPercent: number, bytesWritten: number, fileSize: number }) => any;
onUploadProgress?: (progressPercent: number, args: {bytesWritten: number, fileSize: number }) => any;
}
export interface ApiUploadResponse {