发表更新1 分钟读完 (大约152个字)0次访问
ThinkJS Service 删除阿里云OSS文件
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
| 'use strict';
const OSS = require('ali-oss'); const region = 'oss-cn-shenzhen';
const accessKeyId = '****************'; const accessKeySecret = '******************************'; const bucket = '*****************'; module.exports = class extends think.Service {
async deleteFile(fileName) { try { let client = new OSS({ region, accessKeyId, accessKeySecret, bucket }); let result = await client.delete(fileName); let ret = result.res.status == 204; return ret; } catch (e) { think.logger.info(e); } } }
|
参考