Coding With Fun
Home Docker Django Node.js Articles Python pip guide FAQ Policy

WeChat small program cloud development service side storage API from the cloud storage space to download files


May 20, 2021 WeChat Mini Program Development Document


Table of contents


downloadFile

Download files from cloud storage

Request parameters

Field Description The data type The default Required
fileID Cloud file ID String - Y

Promise returns parameters

Field Description The data type
fileContent The contents of the file Buffer
statusCode The HTTP status code returned by the server Number

The argument was returned incorrectly

Field Description The data type
errCode Error code Number
errMsg Error message, format apiName:fail msg String

Use the example

Promise style

const cloud = require('wx-server-sdk')

exports.main = async (event, context) => {
  const fileID = 'xxxx'
  const res = await cloud.downloadFile({
    fileID: fileID,
  })
  const buffer = res.fileContent
  return buffer.toString('utf8')
}