module.exports = { upload () { let client = new OSS({ region: 'oss-cn-beijing', // 云账号AccessKey有所有API访问权限,建议遵循阿里云安全最佳实践,部署在服务端使用RAM子账号或STS,部署在客户端使用STS。 accessKeyId: 'LTAIOxxDqJpJbzfy', accessKeySecret: 'kZRbbX3nNtxWlx5XWsR8uRrJzj4X5C', bucket: 'happycars', }); CO(function * () { client.useBucket('happycars'); // let ret = yield client.list(); // yield client.get(''); // for (let i = 0; i < ret.objects.length; i++) { // let item = ret.objects[i]; // console.log(i + ": " + item.url); // } // console.log(ret); function * listDir (dir) { let list = yield client.list({ prefix: dir, delimiter: '/', }); list.prefixes.forEach((subDir) => { console.log('目录: ' + subDir); }); list.objects.forEach((obj) => { console.log('文件: ' + obj.name); }); } yield listDir('hot'); }).catch((err) => { console.log(err); }); }, };