May 20, 2021 WeChat Mini Program Development Document
Support: small programs, cloud functions, web
Delete files from cloud storage up to 50 at a time
An array of cloud file ID strings
Property | Type | Description |
---|---|---|
fileList | Object | The list of files |
The structure of fileList
Property | Type | Description |
---|---|---|
fileID | string | Cloud file ID |
status | number | Status code, 0 is successful |
errMsg | string | Success is ok and failure is the cause of failure |
Promise style
wx.cloud.deleteFile({
fileList: ['a7xzcb']
}).then(res => {
// handle success
console.log(res.fileList)
}).catch(error => {
// handle error
})
Callback style
wx.cloud.deleteFile({
fileList: ['a7xzcb'],
success: res => {
// handle success
console.log(res.fileList)
},
fail: err => {
// handle error
},
complete: res => {
// ...
}
})
const cloud = require('wx-server-sdk')
cloud.init({
env: cloud.DYNAMIC_CURRENT_ENV
})
exports.main = async (event, context) => {
const fileIDs = ['xxx', 'xxx']
const result = await cloud.deleteFile({
fileList: fileIDs,
})
return result.fileList
}