Commit 8e7db100 authored by 成旭东's avatar 成旭东

oss直传 问题解决

parent d01f8347
Pipeline #28222 passed with stage
in 3 minutes 42 seconds
......@@ -48,7 +48,10 @@
"@ant-design/icons": "^4.0.0",
"@ant-design/pro-layout": "^5.0.16",
"@ant-design/pro-table": "2.3.4",
"@types/ali-oss": "^6.0.5",
"ali-oss": "^6.10.0",
"antd": "4.3.3",
"axios": "^0.20.0",
"classnames": "^2.2.6",
"lodash": "^4.17.11",
"moment": "^2.25.3",
......
import { getOssConfig } from '@/services/media';
import { extend } from 'umi-request';
import { getOssConfig, uploadOss } from '@/services/media';
import moment from 'moment';
export interface MediaModelType {
......@@ -29,30 +28,19 @@ const MediaModel: MediaModelType = {
formData.append('signature', ossConfig.res.signature);
formData.append('file', file);
const response = yield call(uploadOss, formData);
if (response && response.status && response.status === 200 && callback) {
callback({
url: `https://wf.51gjj.com/${ossFilename}`,
});
}
// const response = yield call(upload, formData);
// if (callback) {
// callback(response);
// }
const request = extend({
timeout: 60000,
headers: {
'Content-Type': 'multipart/form-data'
}
});
request.post('https://wafang.oss-cn-hangzhou.aliyuncs.com/', {
data: formData,
}).then(() => {
if (callback) {
callback({
url: `https://wafang.oss-accelerate.aliyuncs.com/${ossFilename}`,
});
}
}).catch((error) => {
console.log(error);
});
},
},
......
import request from '@/utils/request';
import axios from 'axios';
export async function upload(params: any) {
return request('/upload/media', {
......@@ -12,3 +13,13 @@ export async function getOssConfig() {
method: 'GET',
});
}
export async function uploadOss(formData: any) {
const config = {
headers: {
'Content-Type': 'multipart/form-data'
}
};
return axios.post('https://wafang.oss-cn-hangzhou.aliyuncs.com/', formData, config)
}
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