Commit d38924f0 by renmanyi

feat:分片上传兼容腾讯云

parent bfbbdaaf
...@@ -21,7 +21,8 @@ ...@@ -21,7 +21,8 @@
"@types/underscore": "^1.10.22", "@types/underscore": "^1.10.22",
"@typescript-eslint/eslint-plugin": "^2.10.0", "@typescript-eslint/eslint-plugin": "^2.10.0",
"@typescript-eslint/parser": "^2.10.0", "@typescript-eslint/parser": "^2.10.0",
"ali-oss": "6.17.1", "ali-oss": "^6.23.0",
"cos-js-sdk-v5": "^1.10.1",
"antd": "^4.16.3", "antd": "^4.16.3",
"array-move": "^3.0.1", "array-move": "^3.0.1",
"axios": "^0.20.0", "axios": "^0.20.0",
......
/* /*
* @Author: 吴文洁 * @Author: 吴文洁
* @Date: 2020-08-31 09:34:51 * @Date: 2020-08-31 09:34:51
* @LastEditors: wufan * @LastEditors: renmanyi
* @LastEditTime: 2021-01-06 20:18:46 * @LastEditTime: 2026-02-03 15:29:54
* @Description: * @Description:
* @Copyright: 杭州杰竞科技有限公司 版权所有 * @Copyright: 杭州杰竞科技有限公司 版权所有
*/ */
...@@ -34,10 +34,7 @@ class Service { ...@@ -34,10 +34,7 @@ class Service {
static get(url: string, params: any, option?: any) { static get(url: string, params: any, option?: any) {
return Axios.post('GET', url, params, option); return Axios.post('GET', url, params, option);
} }
static MFS(url: string, params: any, option: any) {
return Axios.post('POST', `mfs/${url}`, params, option);
}
} }
export default Service; export default Service;
\ No newline at end of file
/* /*
* @Author: wufan * @Author: wufan
* @Date: 2020-12-01 17:21:21 * @Date: 2020-12-01 17:21:21
* @LastEditors: Please set LastEditors * @LastEditors: renmanyi
* @LastEditTime: 2021-07-09 15:33:33 * @LastEditTime: 2026-02-03 15:38:02
* @Description: Description * @Description: Description
* @@Copyrigh: © 2020 杭州杰竞科技有限公司 版权所有 * @@Copyrigh: © 2020 杭州杰竞科技有限公司 版权所有
*/ */
...@@ -72,11 +72,12 @@ export const getOssClient = ( ...@@ -72,11 +72,12 @@ export const getOssClient = (
resourceName: string, resourceName: string,
accessTypeEnum: string accessTypeEnum: string
) => { ) => {
return Service.postJSON('mfs/anon/mfs/multiPartUpload', { return Service.postJSON('business/public/mfs/commonUpload', {
data, data,
instId, instId,
bizCode, bizCode,
resourceName, resourceName,
needSecret: true,
accessTypeEnum accessTypeEnum
}); });
} }
......
/* /*
* @Author: 吴文洁 * @Author: 吴文洁
* @Date: 2020-10-10 18:21:47 * @Date: 2020-10-10 18:21:47
* @LastEditors: wufan * @LastEditors: renmanyi
* @LastEditTime: 2020-12-09 16:05:24 * @LastEditTime: 2026-02-03 15:38:06
* @Description: * @Description:
* @Copyright: 杭州杰竞科技有限公司 版权所有 * @Copyright: 杭州杰竞科技有限公司 版权所有
*/ */
...@@ -15,11 +15,12 @@ export const getOssClient = ( ...@@ -15,11 +15,12 @@ export const getOssClient = (
resourceName: string, resourceName: string,
accessTypeEnum: string accessTypeEnum: string
) => { ) => {
return Service.postJSON('mfs/anon/mfs/multiPartUpload', { return Service.postJSON('business/public/mfs/commonUpload', {
data, data,
instId, instId,
bizCode, bizCode,
resourceName, resourceName,
needSecret: true,
accessTypeEnum accessTypeEnum
}); });
} }
\ No newline at end of file
/* /*
* @Author: 吴文洁 * @Author: 吴文洁
* @Date: 2020-10-10 18:19:34 * @Date: 2020-10-10 18:19:34
* @LastEditors: 吴文洁 * @LastEditors: renmanyi
* @LastEditTime: 2020-10-13 18:09:39 * @LastEditTime: 2026-02-03 15:39:33
* @Description: * @Description:
* @Copyright: 杭州杰竞科技有限公司 版权所有 * @Copyright: 杭州杰竞科技有限公司 版权所有
*/ */
import OSS from 'ali-oss'; import OSS from 'ali-oss';
import COS from 'cos-js-sdk-v5';
import { UPLOAD_REGION } from '@/domains/resource-disk/constants'; import { UPLOAD_REGION } from '@/domains/resource-disk/constants';
import { getOssClient } from '@/data-source/basic/basic-apis'; import { getOssClient } from '@/data-source/basic/basic-apis';
...@@ -31,32 +32,26 @@ export default class UploadFileService { ...@@ -31,32 +32,26 @@ export default class UploadFileService {
accessTypeEnum accessTypeEnum
).then((res) => { ).then((res) => {
const { result = {} } = res; const { result = {} } = res;
const { const { bucket, resourceId, accessKeyId, securityToken, accessKeySecret, key, vendorType, callbackData, callback } = result;
bucket, let client;
callBack, if (vendorType === 'TENCENT_COS') {
resourceId, // 腾讯云配置
accessKeyId, client = new COS({
securityToken, SecretId: accessKeyId,
accessKeySecret, SecretKey: accessKeySecret,
callbackBody, SecurityToken: securityToken
ossUri });
} = result; } else {
// 阿里云配置
const ossClient = new OSS({ client = new OSS({
bucket, bucket,
accessKeyId, accessKeyId,
accessKeySecret, accessKeySecret,
region: UPLOAD_REGION, region: UPLOAD_REGION,
stsToken: securityToken, stsToken: securityToken
}); });
}
resolve({ resolve({ ossClient: client, resourceId, ossUri:key, vendorType,bucket,callbackData,callback });
ossClient,
resourceId,
callBack,
callbackBody,
ossUri
});
}) })
}) })
} }
......
/* /*
* @Author: 吴文洁 * @Author: 吴文洁
* @Date: 2020-08-20 09:21:40 * @Date: 2020-08-20 09:21:40
* @LastEditors: yuananting * @LastEditors: renmanyi
* @LastEditTime: 2021-07-15 11:48:58 * @LastEditTime: 2026-02-03 15:45:43
* @Description: * @Description:
* @Copyright: 杭州杰竞科技有限公司 版权所有 * @Copyright: 杭州杰竞科技有限公司 版权所有
*/ */
...@@ -172,6 +172,7 @@ const NON_COMPLIANT_FILE_MAP = { ...@@ -172,6 +172,7 @@ const NON_COMPLIANT_FILE_MAP = {
// 文件上传 // 文件上传
const UPLOAD_REGION = 'oss-cn-hangzhou'; const UPLOAD_REGION = 'oss-cn-hangzhou';
const TX_UPLOAD_REGION = 'ap-shanghai';
const UPLOAD_PART_SIZE = 1024 * 1024; // 每个分片大小(byte) const UPLOAD_PART_SIZE = 1024 * 1024; // 每个分片大小(byte)
const UPLOAD_PARALLEL = 5; // 同时上传的分片数 const UPLOAD_PARALLEL = 5; // 同时上传的分片数
...@@ -185,6 +186,7 @@ export { ...@@ -185,6 +186,7 @@ export {
DISK_MAP, DISK_MAP,
SUFFIX_MAP, SUFFIX_MAP,
UPLOAD_REGION, UPLOAD_REGION,
TX_UPLOAD_REGION,
UPLOAD_PART_SIZE, UPLOAD_PART_SIZE,
UPLOAD_PARALLEL, UPLOAD_PARALLEL,
} }
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment