fix: 上传切片文件并发送文件到网元端
This commit is contained in:
@@ -1,4 +1,8 @@
|
||||
import { RESULT_CODE_ERROR, RESULT_CODE_SUCCESS, RESULT_MSG_ERROR } from '@/constants/result-constants';
|
||||
import {
|
||||
RESULT_CODE_ERROR,
|
||||
RESULT_CODE_SUCCESS,
|
||||
RESULT_MSG_ERROR,
|
||||
} from '@/constants/result-constants';
|
||||
import { request, language } from '@/plugins/http-fetch';
|
||||
import { encode } from 'js-base64';
|
||||
|
||||
@@ -194,3 +198,33 @@ export function chunkUpload(data: FormData) {
|
||||
dataType: 'form-data',
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 上传切片文件并发送文件到网元端
|
||||
* @param neType 网元类型, UPF
|
||||
* @param neId 网元标识, 001
|
||||
* @param fileData 文件对象
|
||||
* @param chunkSize 数据块大小MB,默认1MB
|
||||
* @returns
|
||||
*/
|
||||
export async function uploadFileToNE(
|
||||
neType: string,
|
||||
neId: string,
|
||||
fileData: File,
|
||||
chunkSize: number = 1
|
||||
) {
|
||||
const uploadChunkRes = await uploadFileChunk(fileData, chunkSize, 'import');
|
||||
if (uploadChunkRes.code === RESULT_CODE_SUCCESS) {
|
||||
const transferToNeFileRes = await request({
|
||||
url: `/ne/action/pushFile`,
|
||||
method: 'post',
|
||||
data: {
|
||||
uploadPath: uploadChunkRes.data.fileName,
|
||||
neType,
|
||||
neId,
|
||||
},
|
||||
});
|
||||
return transferToNeFileRes;
|
||||
}
|
||||
return uploadChunkRes;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user