UNPKG

s3-readstream

Version:

*Updated for AWS-SDK v3* Zero dependency S3Client streaming solution

44 lines (43 loc) 1.53 kB
/// <reference types="node" /> import { Readable, ReadableOptions } from "stream"; import type { S3Client, GetObjectCommand } from "@aws-sdk/client-s3"; export declare type S3ReadStreamOptions = { s3: S3Client; command: GetObjectCommand; maxLength: number; byteRange?: number; }; export declare class S3ReadStream extends Readable { _s3: S3Client; _command: GetObjectCommand; _currentCursorPosition: number; _s3DataRange: number; _maxContentLength: number; constructor(options: S3ReadStreamOptions, nodeReadableStreamOptions?: ReadableOptions); private drainBuffer; /** * Adjust size of range to grab from S3 * * @param {number} bytes - Number of bytes to set for range */ adjustByteRange(bytes: number): void; /** * Drains the internal buffer and * moves cursor bytes length back in file * * If current cursor position - number of bytes to move back * is <= 0, set cursor at begining of file * @param {number} bytes - Number of bytes to subtract from cursor (defaults to range) */ moveCursorBack(bytes?: number): void; /** * Drains the internal buffer and * moves cursor bytes length forward in file * * If current cursor position + number of bytes to move forward * is > the length of the file, set cursor at end of file * @param {number} bytes - Number of bytes to add to cursor (defaults to range) */ moveCursorForward(bytes?: number): void; _read(): Promise<void>; }