ai-bot/app/_lib/test/oss.ts

20 lines
622 B
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

const OSS = require('ali-oss');
// 创建OSS实例
const client = new OSS({
accessKeyId: 'LTAI5tNzopZHJFa2Q9vqr1u5',
accessKeySecret: 'qPu7fyft0KJ1l6SGqbS71IW0vDbRlr'
// 先不指定region和bucket以便后续查询
});
// 列出所有Bucket
client.listBuckets().then((result) => {
console.log('所有的Bucket:', result.buckets);
// 打印每个Bucket的信息
result.buckets.forEach((bucket) => {
console.log('Bucket名称:', bucket.name);
console.log('Bucket所在区域:', bucket.location);
});
}).catch((error) => {
console.error('列出Bucket失败:', error);
});