import { downloadFile, uploadFile } from '@ray-js/ray'
// 监听上传进度:拿到 UploadTask 后注册 onProgressUpdate,上传过程中回调进度
downloadFile({
url: "https://airtake-public-data-1254153901.cos.ap-shanghai.myqcloud.com/ttttestfile/test_image.jpg",
success: ({ tempFilePath }) => {
const task = uploadFile({
url: "https://httpbin.org/post",
filePath: tempFilePath,
name: "file",
success: () => console.log("上传完成"),
fail: error => console.error(error),
});
task.onProgressUpdate(e => {
console.log("上传进度:", e.progress, e.totalBytesSent, "/", e.totalBytesExpectedToSend);
});
},
fail: error => console.error(error),
});