Commit 8df8405e authored by zhengke's avatar zhengke

上传图

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