Skip to content
This repository has been archived by the owner on Feb 15, 2023. It is now read-only.

juristat/stream-s3-object

Repository files navigation

stream-s3-object

Usage

const AWS = require('aws-sdk')
const streamS3Object = require('stream-s3-object')
const s3 = new AWS.S3()

const getObjectRequest = s3.getObject({ /* whatever */ })
const { getHeader, headers, stream } = await streamS3Object(getObjectRequest)

Returned properties

The function returns an object containing the following properties asynchronously (i.e. as a Promise):

  • getHeader(name: string): string?
    • Get the string value of the specified header name (or undefined), with case-insensitive matching
  • headers: { [name: string]: string }
    • The exact headers object returned from the AWS SDK
  • stream: stream.Readable
    • A readable stream representing the S3 object being retrieved, from s3.getObject(...).createReadStream()

Errors

The streamS3Object() call will throw a TypeError synchronously if the input doesn't appear to be a request object from the s3 getObject() method. The returned Promise will be rejected with the error value from any httpError event that is raised on the getObject() request.

See Also

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

No packages published