Commit 8df8405e authored by zhengke's avatar zhengke

上传图

parent 47c63d8f
......@@ -3,7 +3,7 @@ export const domainManager = () => {
const obj = {
domainUrl: locationName.indexOf('oytour') !== -1 ? "http://reborn.oytour.com/api/common/post" : "http://192.168.10.214/api/common/post",
//上传站点
UploadUrl: locationName.indexOf('oytour') !== -1 ? "http://upload.oytour.com" : "http://192.168.10.214:8120",
UploadUrl: locationName.indexOf('oytour') !== -1 ? "http://upload.oytour.com" : "http://192.168.5.46:8120",
//文件站点
ViittoFileUrl: locationName.indexOf('oytour') !== -1 ? "http://imgfile.oytour.com" : 'http://192.168.10.214:8130',
// 通知erp
......
import { domainManager } from '@/utils/domainManager'
class AliyunUpload {
static readonly REGION = 'oss-cn-chengdu'
static readonly ACCESS_KEY_ID = 'LTAI5tFgqt1pwnoA35cigYTr'
static readonly ACCESS_KEY_SECRET = 'wXPoEqJ7qLdvX9iBluIebhCPSzoemy'
static readonly BUCKET = 'vt-im-bucket'
static GetOSS = () => {
const OSS = require('ali-oss');
//return new OSS
return new OSS({
region:this.REGION,
accessKeyId:this.ACCESS_KEY_ID,
accessKeySecret:this.ACCESS_KEY_SECRET,
bucket:this.BUCKET
})
}
static UploadAsync = async (file:any,name:string)=>{
try {
const oss = this.GetOSS()
const headers = {
'Cache-Control':'public,max-age=31536000'
};
let result = await oss.put(name,file,{headers})
return 'https://im.oytour.com/'+name//result.url
let path = "/Sale/Uploadvideo/"
const formData = new FormData();
formData.append('file', file);
const response = await fetch(`${domainManager().UploadUrl}/Upload/UploadToALiOSS?filePath=${path}`, {
method: 'POST',
body: formData,
});
if(response.ok){
let result = await response.text()
let datas = JSON.parse(result)
return datas.FilePath
}
return ''
} catch (error) {
return ''
}
......
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