$ npm i egg-aws-s3 --save
// {app_root}/config/plugin.js
exports.awsS3 = {
enable: true,
package: 'egg-aws-s3',
};
// {app_root}/config/config.default.js
exports.awsS3 = {
client: {
convertAsync: true, // plugin owner property, while this flag is true, s3 client object will add async function
sslEnabled: false,
s3ForcePathStyle: true,
signatureVersion: 'v2',
},
app: true,
agent: false,
};
see aws document contructor property for more client detail.
app.awsS3.listBuckets({}, (err, data) => {
if (err)
console.log(err);
console.log(data);
});
// while convertAsync is enable, you can use async/await like
try {
const data = await app.awsS3.listBucketsAsync({});
console.log(data);
} catch (err) {
console.log(err);
}
see aws document method summary for APIs.
Please open an issue here.