Options
All
  • Public
  • Public/Protected
  • All
Menu

The ManagedDownloader class handles custom S3 downloads. A client can set options for the download such as the part size and the concurrency.

Hierarchy

  • ManagedDownloader

Index

Constructors

constructor

  • Create a ManagedDownloader object with an s3 client and custom options if provided.

    throws

    Error if the client is not provided.

    throws

    Error if maxPartSize is not a positive number.

    throws

    Error if concurrency is not a positive number.

    Parameters

    • client: S3

      an S3 client to make requests.

    • Default value options: ManagedDownloaderOptions = {}

      configuration for the managed download.

    Returns ManagedDownloader

Properties

Private client

client: S3

an S3 client to make requests.

Private maxConcurrency

maxConcurrency: number

Private maxPartSize

maxPartSize: number
param

max part size of download in bytes.

param

maximum parallel downloads.

Methods

Private downloadByParts

  • Download the individual parts of the file and write them to the stream sequentially. Download n = this.maxConcurrency parts in parallel and store parts which aren't the next part in memory until the stream is ready to read it.

    Parameters

    • params: GetObjectStreamInput

      params object contains the bucket and key.

    • destinationStream: ManagedDownloaderStream

      the ManagedDownloaderStream stream transferring the parts of a file.

    • contentLength: number

      the length of the file.

    • Default value byteOffset: number = 0

      if available, the amount to add to start and end byte when calculating the range.

    • Default value startingPart: number = 0

      the part number to start downloading from.

    Returns Promise<void>

getObjectStream

  • Get a download stream for a file stored in s3. Download the first part of size [maxPartSize] to get the content length and set headers for the stream. If the file length is less than [maxPartSize], or the client provides a part number, then return the stream. If not, call downloadByParts to split the rest of the file into parts of size [maxPartSize] and download [maxConcurrency] parts in parallel.

    throws

    Error if params is in the incorrect format.

    Parameters

    • params: GetObjectStreamInput

      an object in the format { Bucket:string, Key:string, Range(optional):string, PartNumber(optional):number }.

    Returns Promise<ManagedDownloaderStream>

    ManagedDownloaderStream the PassThrough stream to read file data from.

Private waitForDrainEvent

  • wait for a stream to emit a drain event when it is ready to receive data again.

    Parameters

    Returns Promise<void>

Generated using TypeDoc