优化文件下载逻辑.

This commit is contained in:
lijiahangmax
2024-10-10 23:18:53 +08:00
parent c229029c1d
commit 6e977dabf6
22 changed files with 357 additions and 48 deletions

View File

@@ -63,10 +63,35 @@ export function deleteHostSftpLog(idList: Array<number>) {
});
}
/**
* 获取 SFTP 文件内容
*/
export function getSftpFileContent(token: string) {
return axios.get<string>('/asset/host-sftp/get-content', {
unwrap: true,
params: { token },
timeout: 60000
});
}
/**
* 设置 SFTP 文件内容
*/
export function setSftpFileContent(token: string, content: string) {
const formData = new FormData();
formData.append('token', token);
formData.append('file', new File([content], Date.now() + '', { type: 'text/plain' }));
return axios.post<boolean>('/asset/host-sftp/set-content', formData, {
timeout: 60000,
headers: {
'Content-Type': 'multipart/form-data'
}
});
}
/**
* 下载文件
*/
export function getDownloadTransferUrl(channelId: string, transferToken: string) {
return `${httpBaseUrl}/asset/host-sftp/download?channelId=${channelId}&transferToken=${transferToken}`;
}