Skip to content

mrrtree/egg-aws-s3

Repository files navigation

egg-aws-s3

NPM version build status Test coverage David deps npm download

Install

$ npm i egg-aws-s3 --save

Usage

// {app_root}/config/plugin.js
exports.awsS3 = {
  enable: true,
  package: 'egg-aws-s3',
};

Configuration

// {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.

Example

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.

Questions & Suggestions

Please open an issue here.

License

MIT

About

official S3 sdk for egg

Resources

License

Stars

Watchers

Forks

Packages

No packages published