微信小程序
deleteFile
# Cloud.deleteFile(fileList: string[]): Promise<Object>
支持端:小程序 , 云函数 , Web
从云存储空间删除文件,一次最多 50 个
# 参数
# fileList: string[]
云文件 ID 字符串数组
# 返回值
# Promise.<Object>
fileList 的结构
# 小程序端示例
Promise 风格
wx.cloud.deleteFile({
fileList: ['a7xzcb']
}).then(res => {
// handle success
console.log(res.fileList)
}).catch(error => {
// handle error
})
Callback 风格
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
}