Commit bfbbdaaf by renmanyi

feat:上传改造

parent 741ac6dd
import { func } from "prop-types";
import Service from '@/common/js/service';
import User from '@/common/js/user';
import { message } from 'antd';
......@@ -6,7 +5,7 @@ import { message } from 'antd';
* @Author: 吴文洁
* @Date: 2020-08-11 11:47:14
* @LastEditors: renmanyi
* @LastEditTime: 2026-02-03 14:29:56
* @LastEditTime: 2026-02-03 15:28:25
* @Description:
* @Copyright: 杭州杰竞科技有限公司 版权所有
*/
......@@ -118,25 +117,42 @@ class Upload {
resourceName: name,
}
Service.Hades('/public/hades/ossAuthority', params).then((res) => {
const { resourceId, accessId, policy, callback, signature,key, host } = res.result;
const xhr = new XMLHttpRequest();
const formData = new FormData();
formData.append("OSSAccessKeyId", accessId);
formData.append("policy", policy);
formData.append("callback", callback);
formData.append("Signature", signature);
formData.append("key", key);
formData.append("file", new Blob([string]));
formData.append("success_action_status", 200);
xhr.open("POST", host);
xhr.onload = () => {
success(resourceId);
};
xhr.onerror = () => {
error();
const signInfo = res.result;
const { resourceId } = res.result;
if (signInfo.vendorType === 'TENCENT_COS') {
// 腾讯云 COS 上传
this.uploadBlobToNewOSSTx(new Blob([string]), name, signInfo.signatureVO || signInfo).then(() => {
success(resourceId);
}).catch(() => {
error();
});
} else {
// 阿里云 OSS 上传
const { accessId, policy, callback, signature, key, host } = signInfo;
const xhr = new XMLHttpRequest();
const formData = new FormData();
formData.append("OSSAccessKeyId", accessId);
formData.append("policy", policy);
formData.append("callback", callback);
formData.append("Signature", signature);
formData.append("key", key);
if(signInfo.securityToken) {
formData.append("x-oss-security-token", signInfo.securityToken);
}
formData.append("file", new Blob([string]));
formData.append("success_action_status", 200);
xhr.open("POST", host);
xhr.onload = () => {
success(resourceId);
};
xhr.onerror = () => {
error();
}
xhr.send(formData);
}
xhr.send(formData);
})
}).catch(() => {
error();
});
}
}
......
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