reactor:【INFRA】文件上传 api,增加 directory 参数,去除 path 参数,并支持按照日期分目录、文件名不再使用 sha256 而是时间戳

This commit is contained in:
YunaiV
2025-05-02 19:59:05 +08:00
parent 368f7c753f
commit 91d70b41cb
8 changed files with 41 additions and 34 deletions

View File

@@ -23,12 +23,13 @@ export namespace InfraFileApi {
configId: number; // 文件配置编号
uploadUrl: string; // 文件上传 URL
url: string; // 文件 URL
path: string; // 文件路径
}
/** 上传文件 */
export interface FileUploadReqVO {
file: globalThis.File;
path?: string;
directory?: string;
}
}
@@ -45,11 +46,11 @@ export function deleteFile(id: number) {
}
/** 获取文件预签名地址 */
export function getFilePresignedUrl(path: string) {
export function getFilePresignedUrl(name: string, directory?: string) {
return requestClient.get<InfraFileApi.FilePresignedUrlRespVO>(
'/infra/file/presigned-url',
{
params: { path },
params: { name, directory },
},
);
}
@@ -64,5 +65,9 @@ export function uploadFile(
data: InfraFileApi.FileUploadReqVO,
onUploadProgress?: AxiosProgressEvent,
) {
// 特殊:由于 upload 内部封装,即使 directory 为 undefined也会传递给后端
if (!data.directory) {
delete data.directory;
}
return requestClient.upload('/infra/file/upload', data, { onUploadProgress });
}