[midway.js]微信小程序二维码获取Buffer文件上传腾讯云cos

请求接口

let url =
      'https://api.weixin.qq.com/wxa/getwxacodeunlimit?access_token=' +
      data.access_token;
    let data2 = {
      path: data.data.path,
      scene: data.data.scene,
    };
    let data1 = await this.httpService.post(url, data2, {
      headers: {
        'Content-Type': 'application/x-www-form-urlencoded;charset=utf-8',
      },
      responseType: 'arraybuffer',
    });

存储二进制文件到腾讯云cos

await this.cosService
      .putObject({
        Bucket: '',
        Region: '',
        Key:
          new Date().getTime() +   //自行更改生成文件名字和存储目录
          '.jpg',
        Body: data1.data,
      })
      .then(data => {
        console.log(data.Location) //图片地址
      })
      .catch(err => {
      });

你可能感兴趣的:(环境搭建,midway.js,node,微信小程序,javascript,腾讯云)