|
|
|
@ -1,3 +1,10 @@
|
|
|
|
|
/*
|
|
|
|
|
* @Author: ch
|
|
|
|
|
* @Date: 2022-07-07 17:27:04
|
|
|
|
|
* @LastEditors: ch
|
|
|
|
|
* @LastEditTime: 2022-07-09 11:14:35
|
|
|
|
|
* @Description: file content
|
|
|
|
|
*/
|
|
|
|
|
import request from '@/utils/request';
|
|
|
|
|
// OSS签名
|
|
|
|
|
export function sign(serviceName, configId) {
|
|
|
|
@ -9,23 +16,26 @@ export function sign(serviceName, configId) {
|
|
|
|
|
configId,
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
// console.info(serviceName, configId);
|
|
|
|
|
// return {
|
|
|
|
|
// accessId: 'LTAI4GHRNb5Xn2w5NeHVbR4c',
|
|
|
|
|
// policy: 'eyJleHBpcmF0aW9uIjoiMjAyMi0wNC0xNVQyMDowODoyNi4zMTlaIiwiY29uZGl0aW9ucyI6W1siY29udGVudC1sZW5ndGgtcmFuZ2UiLDAsMTA0ODU3NjAwMF0sWyJzdGFydHMtd2l0aCIsIiRrZXkiLCJ0ZXN0LyJdXX0=',
|
|
|
|
|
// signature: 'okaB3sNp3vzyfM0S3ypudaUAZ+0=',
|
|
|
|
|
// dir: 'test/',
|
|
|
|
|
// host: 'https://msb-edu-dev.oss-cn-beijing.aliyuncs.com',
|
|
|
|
|
// expire: '1650053306',
|
|
|
|
|
// };
|
|
|
|
|
}
|
|
|
|
|
export function payCenterSign() {
|
|
|
|
|
return request({
|
|
|
|
|
url: '/payCenter/oss/ossSignature',
|
|
|
|
|
method: 'GET',
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 上传文件
|
|
|
|
|
export async function upload(serviceName, configId, file, cancelToken) {
|
|
|
|
|
let oss = await sign(serviceName, configId);
|
|
|
|
|
let oss = {};
|
|
|
|
|
if (serviceName) {
|
|
|
|
|
oss = await sign(serviceName, configId);
|
|
|
|
|
} else {
|
|
|
|
|
oss = await payCenterSign();
|
|
|
|
|
}
|
|
|
|
|
// return false;
|
|
|
|
|
let data = new FormData();
|
|
|
|
|
let arr = file.name.split('/');
|
|
|
|
|
arr[arr.length - 1] = encodeURIComponent(arr[arr.length - 1]);
|
|
|
|
|
data.append('name', arr.join('/'));
|
|
|
|
|
let name = file.uid + file.name.substring(file.name.lastIndexOf('.'));
|
|
|
|
|
data.append('name', name);
|
|
|
|
|
data.append('key', `${oss.dir}${'${filename}'}`);
|
|
|
|
|
data.append('policy', oss.policy);
|
|
|
|
|
data.append('OSSAccessKeyId', oss.accessId);
|
|
|
|
|