# wx.cloud.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 |
config | Configuration | Object | - | N |
success | Callback succeeds | |||
fail | Callback fails | |||
complete | Callback completes |
Each element in the fileList array is a cloud file fileID
config object definition
Field | Description | Data Type |
---|---|---|
env | ID of the used environment. Ignore the environment specified by init if this parameter is specified. | String |
success 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 |
fail return parameter
Field | Description | Data Type |
---|---|---|
errCode | Error code | Number |
errMsg | Error message, in the format of apiName:fail msg | String |
# Use Case
Callback style
wx.cloud.getTempFileURL({
fileList: ['cloud://xxx', 'cloud://yyy'],
success: res => {
// get temp file URL
console.log(res.fileList)
},
fail: err => {
// handle error
}
})
Promise style
wx.cloud.getTempFileURL({
fileList: [{
fileID: 'a7xzcb',
maxAge: 60 * 60, // one hour
}]
}).then(res => {
// get temp file URL
console.log(res.fileList)
}).catch(error => {
// handle error
})