feat: oss下载进度(已下载的KB 无法作为进度显示 total返回为null)

This commit is contained in:
dap
2025-01-17 11:13:03 +08:00
parent 77cd005f15
commit 14b7296200
4 changed files with 20 additions and 3 deletions

View File

@@ -1,3 +1,5 @@
import type { AxiosRequestConfig } from '@vben/request';
import type { OssFile } from './model';
import type { ID, IDS, PageQuery, PageResult } from '#/api/common';
@@ -48,13 +50,18 @@ export function ossUpload(file: Blob | File) {
/**
* 下载文件 返回为二进制
* @param ossId ossId
* @param onDownloadProgress 下载进度(可选)
* @returns blob
*/
export function ossDownload(ossId: ID) {
export function ossDownload(
ossId: ID,
onDownloadProgress?: AxiosRequestConfig['onDownloadProgress'],
) {
return requestClient.get<Blob>(`${Api.ossDownload}/${ossId}`, {
responseType: 'blob',
timeout: 30 * 1000,
isTransformResponse: false,
onDownloadProgress,
});
}