@masterfix/s3-streams
TypeScript icon, indicating that this package has built-in type declarations

1.4.0 • Public • Published

s3-streams

A node library which simplifies uploads and downloads of S3 objects.

Installation

npm install @masterfix/s3-streams

Example

import {S3Client} from '@aws-sdk/client-s3';
import {createS3ReadStream} from '@masterfix/s3-streams';
import {createWriteStream} from 'fs';

const s3Client = new S3Client({
  region: 'US',
  endpoint: 'https://eu-central-1.linodeobjects.com',
  credentials: {
    accessKeyId: 'topsecret',
    secretAccessKey: 'topsecret',
  },
});

const readStream = createS3ReadStream({
  s3Client,
  bucket: 'mybucket',
  key: 'remote-file.tar.gz',
});

const writeStream = createWriteStream('local-file.tar.gz');

readStream.pipe(writeStream);

Running Tests

To run tests, run the following command:

npm test

Environment Variables

To run the tests, you will need to add the following environment variables to your .env file:

S3_REGION S3_ENDPOINT S3_ACCESS_KEY S3_SECRET_KEY S3_BUCKET

License

MIT

Package Sidebar

Install

npm i @masterfix/s3-streams

Weekly Downloads

0

Version

1.4.0

License

MIT

Unpacked Size

13.4 kB

Total Files

12

Last publish

Collaborators

  • masterfix