diff --git a/.env.dev b/.env.dev index 3c41cc68..689718b2 100644 --- a/.env.dev +++ b/.env.dev @@ -7,6 +7,8 @@ VITE_DEV=true VITE_BASE_URL='http://api-dashboard.yudao.iocoder.cn' # VITE_BASE_URL='http://dofast.demo.huizhizao.vip:20001' +# 文件上传类型:server - 后端上传, client - 前端直连上传,仅支持S3服务 +VITE_UPLOAD_TYPE=server # 上传路径 VITE_UPLOAD_URL='http://api-dashboard.yudao.iocoder.cn/admin-api/infra/file/upload' diff --git a/.env.local b/.env.local index 2eb968c4..28f37538 100644 --- a/.env.local +++ b/.env.local @@ -6,6 +6,8 @@ VITE_DEV=true # 请求路径 VITE_BASE_URL='http://localhost:48080' +# 文件上传类型:server - 后端上传, client - 前端直连上传,仅支持S3服务 +VITE_UPLOAD_TYPE=server # 上传路径 VITE_UPLOAD_URL='http://localhost:48080/admin-api/infra/file/upload' diff --git a/.env.prod b/.env.prod index 070b43a7..35d729c3 100644 --- a/.env.prod +++ b/.env.prod @@ -6,6 +6,8 @@ VITE_DEV=false # 请求路径 VITE_BASE_URL='http://localhost:48080' +# 文件上传类型:server - 后端上传, client - 前端直连上传,仅支持S3服务 +VITE_UPLOAD_TYPE=server # 上传路径 VITE_UPLOAD_URL='http://localhost:48080/admin-api/infra/file/upload' diff --git a/.env.stage b/.env.stage index c0edf340..26f9516b 100644 --- a/.env.stage +++ b/.env.stage @@ -6,6 +6,8 @@ VITE_DEV=false # 请求路径 VITE_BASE_URL='http://api-dashboard.yudao.iocoder.cn' +# 文件上传类型:server - 后端上传, client - 前端直连上传,仅支持S3服务 +VITE_UPLOAD_TYPE=server # 上传路径 VITE_UPLOAD_URL='http://api-dashboard.yudao.iocoder.cn/admin-api/infra/file/upload' diff --git a/.env.test b/.env.test index 217ac6e2..addbfb4e 100644 --- a/.env.test +++ b/.env.test @@ -6,6 +6,8 @@ VITE_DEV=false # 请求路径 VITE_BASE_URL='http://localhost:48080' +# 文件上传类型:server - 后端上传, client - 前端直连上传,仅支持S3服务 +VITE_UPLOAD_TYPE=server # 上传路径 VITE_UPLOAD_URL='http://localhost:48080/admin-api/infra/file/upload' diff --git a/src/api/infra/file/index.ts b/src/api/infra/file/index.ts index f64bc0d6..503711f6 100644 --- a/src/api/infra/file/index.ts +++ b/src/api/infra/file/index.ts @@ -6,6 +6,16 @@ export interface FilePageReqVO extends PageParam { createTime?: Date[] } +// 文件预签名地址 Response VO +export interface FilePresignedUrlRespVO { + // 文件配置编号 + configId: number + // 文件上传 URL + uploadUrl: string + // 文件 URL + url: string +} + // 查询文件列表 export const getFilePage = (params: FilePageReqVO) => { return request.get({ url: '/infra/file/page', params }) @@ -15,3 +25,16 @@ export const getFilePage = (params: FilePageReqVO) => { export const deleteFile = (id: number) => { return request.delete({ url: '/infra/file/delete?id=' + id }) } + +// 获取文件预签名地址 +export const getFilePresignedUrl = (fileName: string) => { + return request.get({ + url: '/infra/file/presigned-url', + params: { fileName } + }) +} + +// 创建文件 +export const createFile = (data: any) => { + return request.post({ url: '/infra/file/create', data }) +} diff --git a/src/components/UploadFile/src/UploadFile.vue b/src/components/UploadFile/src/UploadFile.vue index 5e9c8f3a..c91f977a 100644 --- a/src/components/UploadFile/src/UploadFile.vue +++ b/src/components/UploadFile/src/UploadFile.vue @@ -3,11 +3,10 @@ @@ -36,9 +36,10 @@