
class AliyunUpload {
    static readonly REGION = 'oss-cn-chengdu'
    static readonly ACCESS_KEY_ID = 'LTAIwE7l9dImZSa3'
    static readonly ACCESS_KEY_SECRET = 'j47Ajn0d0WzUCIX8Biyj3P2r8QDltI'
    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()
            let result = await oss.put(name,file)
            console.log(result)
            return 'https://im.oytour.com/'+name//result.url
        } catch (error) {
            console.log('上传发生异常：',error)
            return ''
        }
    }
}

export default AliyunUpload