收藏
回答

云函数获取小程序码过慢?

const wxacodeResult = await cloud.openapi.wxacode.get({
    path: event.path || 'pages/index/index',
  })


  const fileExtensionMatches = wxacodeResult.contentType.match(/\/([^\/]+)/)
  const fileExtension = (fileExtensionMatches && fileExtensionMatches[1]) || 'jpg'
  const { OPENID } = cloud.getWXContext()
  console.log(`${OPENID}.${fileExtension}`)
  const uploadResult = await cloud.uploadFile({
    cloudPath: `${OPENID}.${fileExtension}`,
    fileContent: wxacodeResult.buffer,
  })


  if (!uploadResult.fileID) {
    throw new Error(`upload failed with empty fileID and storage server status code ${uploadResult.statusCode}`)
  }


  return uploadResult.fileID
回答关注问题邀请回答
收藏
登录 后发表内容
问题标签