egg-aws-s3
AWS-S3 plugin for Egg.js
NOTE: This plugin just for integrate AWS-S3 into Egg.js, more documentation please visit https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/S3.html.
AWS S3 plugin for Egg
Install
$ npm i @eggplugin/s3 --save
Configuration
exports.s3 = {
enable: true,
package: '@eggplugin/s3',
};
see config/config.default.js for more detail.
Simple instance
exports.s3 = {
client: {
accessKeyId: '',
secretAccessKey: '',
endpoint: '',
},
app: true,
agent: false,
};
Usage:
(async () => {
const s3 = app.s3;
const data = await s3.listBuckets().promise();
const buckets = data.Buckets.map(item => item.Name);
console.log(buckets);
}).catch(console.error);
Multiple instance
exports.s3 = {
default: {
},
clients: {
client1: {
accessKeyId: '',
secretAccessKey: '',
endpoint: '',
},
client2: {
accessKeyId: '',
secretAccessKey: '',
endpoint: '',
},
},
app: true,
agent: false,
};
Usage:
(async () => {
const client1 = app.s3.get('client1');
const client2 = app.s3.get('client2');
const data1 = await client1.listBuckets().promise();
const data2 = await client2.listBuckets().promise();
}).catch(console.error);
Questions & Suggestions
Please open an issue here.
License
MIT