fix: fix uploading percent
This commit is contained in:
parent
ea9c7c3f9b
commit
32e92f8a24
|
@ -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({
|
||||
|
|
|
@ -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 {
|
||||
|
|
Loading…
Reference in New Issue