diff --git a/hello.js b/hello.js index 2bec675d393dde13a714e3af75618a8b0fb5f781..7bdbfc0fffc63fd39314e590b4247b0b85746d3a 100644 --- a/hello.js +++ b/hello.js @@ -2,10 +2,37 @@ 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, () => { console.log(`Example app listening on port ${port}`) -}) \ No newline at end of file +})