feat: 统一FTP配置,本地备份文件浏览

This commit is contained in:
TsMask
2025-05-09 19:13:02 +08:00
parent 8664e72189
commit 571bc840ad
8 changed files with 594 additions and 333 deletions

View File

@@ -15,7 +15,7 @@ import { encode } from 'js-base64';
export async function downloadFile(filePath: string, range?: string) {
return request({
url: `/file/download/${encode(filePath)}`,
method: 'get',
method: 'GET',
headers: range ? { range } : {},
responseType: 'blob',
timeout: 60_000,
@@ -77,7 +77,7 @@ export async function downloadFileChunk(
export function uploadFile(data: FormData) {
return request({
url: '/file/upload',
method: 'post',
method: 'POST',
data,
dataType: 'form-data',
timeout: 180_000,
@@ -168,8 +168,8 @@ export async function uploadFileChunk(
*/
export function chunkCheck(identifier: string, fileName: string) {
return request({
url: '/file/chunkCheck',
method: 'post',
url: '/file/chunk-check',
method: 'POST',
data: { identifier, fileName },
timeout: 60_000,
});
@@ -188,8 +188,8 @@ export function chunkMerge(
subPath: string = 'default'
) {
return request({
url: '/file/chunkMerge',
method: 'post',
url: '/file/chunk-merge',
method: 'POST',
data: { identifier, fileName, subPath },
timeout: 60_000,
});
@@ -202,22 +202,66 @@ export function chunkMerge(
*/
export function chunkUpload(data: FormData) {
return request({
url: '/file/chunkUpload',
method: 'post',
url: '/file/chunk-upload',
method: 'POST',
data,
dataType: 'form-data',
timeout: 60_000,
});
}
/**
* 本地文件列表
* @param path 文件路径
* @param search search prefix
* @returns object
*/
export async function listFile(query: Record<string, any>) {
return request({
url: `/file/list`,
method: 'GET',
params: query,
});
}
/**
* 本地文件获取下载
* @param path 文件路径
* @param fileName 文件名
* @returns object
*/
export async function getFile(path: string, fileName: string) {
return request({
url: `/file`,
method: 'GET',
params: { path, fileName },
responseType: 'blob',
timeout: 60_000,
});
}
/**
* 本地文件删除
* @param path 文件路径
* @param fileName 文件名
* @returns object
*/
export async function delFile(path: string, fileName: string) {
return request({
url: `/file`,
method: 'DELETE',
params: { path, fileName },
});
}
/**
* 转存上传文件到静态资源
* @returns object
*/
export function transferStaticFile(data: Record<string, any>) {
return request({
url: `/file/transferStaticFile`,
method: 'post',
url: `/file/transfer-static-file`,
method: 'POST',
data,
timeout: 60_000,
});
@@ -241,11 +285,12 @@ export async function uploadFileToNE(
if (uploadChunkRes.code === RESULT_CODE_SUCCESS) {
const transferToNeFileRes = await request({
url: `/ne/action/pushFile`,
method: 'post',
method: 'POST',
data: {
uploadPath: uploadChunkRes.data.fileName,
uploadPath: uploadChunkRes.data.filePath,
neType,
neId,
delTemp: true,
},
timeout: 60_000,
});