Commit 14dd7339 authored by sliao's avatar sliao

oss

parent db677ff2
......@@ -2,8 +2,35 @@ const express = require('express')
const app = express()
const port = 3000
const OSS = require('ali-oss')
const client = new OSS({
// yourregion填写Bucket所在地域。以华东1(杭州)为例,Region填写为oss-cn-hangzhou。
region: 'oss-cn-hangzhou',
// 阿里云账号AccessKey拥有所有API的访问权限,风险很高。强烈建议您创建并使用RAM用户进行API访问或日常运维,请登录RAM控制台创建RAM用户。
accessKeyId: 'LTAI5tHf51yCRXf7UfeaVTEJ',
accessKeySecret: 'mk7Y3cMGSm2kp2MDDR3IPUt41IVwzk'
})
async function listBuckets(next) {
try {
// 列举当前账号所有地域下的存储空间。
const result = await client.listBuckets()
console.log(result)
next(result)
} catch (err) {
console.log(err)
}
}
// listBuckets();
app.get('/', (req, res) => {
res.send('Hello World!')
// res.send('123')
listBuckets(result => {
res.send(result)
})
})
app.listen(port, () => {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment