el-upload 直传 oss


      选择APP
      上传到服务器
    
export default {
    data: function() {
      return {
        fileList: [],
        isUpload: false,
        oss: {
          key: "",
          policy: "",
          Signature: "",
          host: "",
          success_action_status: 200,
          callback: ""
        },
        fileUnikey: ''
      }
    },
    methods: {
       // 凭证
      getPolicy(){
        queryPolicy().then((response) => {
          if(response.data.success){
            let result = response.data.data
            let { dir, host, expire, policy, fileName, signature, callback, accessid } = result;

            this.oss.key = dir + fileName
            this.oss.dir = dir
            this.oss.fileName = fileName
            this.oss.name = fileName
            this.oss.expire = expire;
            this.oss.host = host;
            this.oss.policy = policy;
            this.oss.Signature = signature;
            this.oss.callback = callback;
            this.oss.OSSAccessKeyId = accessid;
            this.fileUnikey = result.unikey
          }else{
            this.$message.error(response.data.message)
          }
        }).catch(error => {
          console.error(error)
        })
      },
      uploadApp() {
        const form = this.$refs.form
        form.validate(isValid => {
          if (isValid && this.fileList.length > 0) {
            this.isUpload = true
            const upload = this.$refs.upload
            upload.submit()
          }
        })
      },
    }
}

你可能感兴趣的:(el-upload 直传 oss)