Coder Social home page Coder Social logo

node-s3-extra's Introduction

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.uploadFileOrFolder('my/local/folder/path/', 's3://my-bucket/path/', {
    ACL: 'public-read'
  });

  // or just upload a file
  await s3.uploadFileOrFolder(
    '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

  • contentPath 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.

node-s3-extra's People

Contributors

akofman avatar dependabot[bot] avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

Forkers

jsfix-ci

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.