0.2.3 • Published 3 years ago

s3-extra v0.2.3

Weekly downloads
172
License
MIT
Repository
github
Last release
3 years ago

node-s3-extra Build Status

Convenient extra methods for the AWS.S3 service.

Install

$ npm install s3-extra

Usage

const s3 = require('s3-extra')({ uploadConcurrency: 50 });

// original s3 api services are still reachable
var params = { Bucket: 'bucket', Key: 'key', Body: stream };
s3.putObject(params, (err, data) => {
  console.log(err, data);
});

// plus some extra methods

try {
  // retrieve an S3 object stream from its url
  const objStream = s3.getObjectStream('s3://my-bucket/my/object/filename');

  // upload a folder and keep the same hierarchy
  await s3.upload('my/local/folder/path/', 's3://my-bucket/path/', {
    ACL: 'public-read'
  });

  // or just upload a file
  await s3.upload('my/local/folder/path/file.txt', 's3://my-bucket/path/');
} catch (err) {
  throw err;
}

API

Table of Contents

getObjectStream

Retrieves objects from Amazon S3.

Parameters

  • s3Url string a valid s3 url reprensenting the location of the object to get.
  • params object the same params as the AWS getObject method are accepted. (optional, default {})

Returns object a stream object.

uploadFileOrFolder

Uploads a file or a folder to an Amazon S3 bucket.

Parameters

  • content string a path to a file or a folder to upload.
  • s3Url string a valid s3 url representing the location to put the content.
  • params object the same params as the AWS upload method are accepted. (optional, default {})

Returns object a promise.

License

MIT Licensed. Copyright (c) Alexis Kofman 2019.

0.2.1

3 years ago

0.2.3

3 years ago

0.2.2

3 years ago

0.2.0

3 years ago

0.1.1

5 years ago

0.1.0

5 years ago