JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 2
  • Score
    100M100P100Q35495F
  • License MIT

upload and download S3 objects using streams

Package Exports

  • @masterfix/s3-streams
  • @masterfix/s3-streams/dist/index.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@masterfix/s3-streams) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

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