oss

作者: tomorrow_chen | 来源:发表于2018-10-17 15:53 被阅读7次
        let file = { uri: image.path, type: 'multipart/form-data', name: 'image.png' }
        let fileName = new Date().getTime() + image.filename
        let filePath = 'headImg/' + fileName;
        let request = new FormData()
        request.append('accessKeyId', '*********')
        request.append('accessKeySecret', '*********************')
        request.append('endpoint', 'oss-cn-****.aliyuncs.com')
        request.append('bucket', '******')
        request.append('key', filePath)
        request.append('file', file)
        axios.post('http://*****.oss-cn-****.aliyuncs.com',
          request,
          { headers: { 'Content-Type': 'multipart/form-data' } }
        ).then((response) => {
          let headImgurl = 'http://*****.oss-cn-******.aliyuncs.com/' + filePath
          axios.post('修改头像',
            qs.stringify({
              headImgurl: headImgurl
            })
          ).then((response) => {
            Toast.info('修改成功', 1)
         }).catch((error) => {
            Toast.info('修改失败', 1)
          })
        }).catch((error) => {
          Toast.info('上传失败', 1)
          console.log(error)
        })
    

    相关文章

      网友评论

          本文标题:oss

          本文链接:https://www.haomeiwen.com/subject/lwdrzftx.html