Commit bfbbdaaf by renmanyi

feat:上传改造

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