# getTempFileURL
Gets URL using the cloud file ID. The validity period can be customized, which defaults to one day and should be not longer than one day. Up to 50 URLs can be obtained at a time.
Request parameters
Field | Description | Data Type | Default | Required |
---|---|---|---|---|
fileList | List of cloud file IDs used to get temporary URLs | String[] | - | Y |
Each element in the fileList array is a cloud file fileID
Promise return parameter
Field | Description | Data Type |
---|---|---|
fileList | File list | Object |
Each element in the fileList array is an Object with the following fields
Field | Description | Data Type |
---|---|---|
fileID | Cloud file ID | String |
tempFileURL | Temporary file path | String |
status | Status code. 0 means success | Number |
errMsg | ok means success; displays cause of failure if fails | String |
Error return parameter
Field | Description | Data Type |
---|---|---|
errCode | Error code | Number |
errMsg | Error message, in the format of apiName:fail msg | String |
# Use Case
Promise style
const cloud = require('wx-server-sdk')
exports.main = async (event, context) => {
const fileList = ['cloud://xxx', 'cloud://yyy']
const result = await cloud.getTempFileURL({
fileList: fileList,
})
return result.fileList
}