Options
All
  • Public
  • Public/Protected
  • All
Menu

Module @aws-sdk/lib-storage

@aws-sdk/lib-storage

NPM version NPM downloads

Upload

Upload allows for easy and efficient uploading of buffers, blobs, or streams, using a configurable amount of concurrency to perform multipart uploads where possible. This abstraction enables uploading large files or streams of unknown size due to the use of multipart uploads under the hood.

  import { Upload } from "@aws-sdk/lib-storage";
  import { S3Client, S3 } from "@aws-sdk/client-s3";

  const target = { Bucket, Key, Body };
  try {
    const paralellUploads3 = new Upload({
      client: new S3({}) || new S3Client({}),
      tags: [...], // optional tags
      queueSize: 4, // optional concurrency configuration
      partSize: 5MB, // optional size of each part
      leavePartsOnError: false, // optional manually handle dropped parts
      params: target,
    });

    paralellUploads3.on("httpUploadProgress", (progress) => {
      console.log(progress);
    });

    await paralellUploads3.done();
  } catch (e) {
    console.log(e);
  }

Index

References

BodyDataTypes

Re-exports BodyDataTypes

Configuration

Re-exports Configuration

Options

Re-exports Options

Progress

Re-exports Progress

RawDataPart

Re-exports RawDataPart

ServiceClients

Re-exports ServiceClients

Upload

Re-exports Upload

Type aliases

BodyDataTypes

BodyDataTypes: PutObjectCommandInput["Body"]

ServiceClients

ServiceClients: S3Client

Variables

Const Body

Body: "Duo Reges: constructio interrete. Qui autem esse poteris, nisi te amor ipse ceperit? Hoc est non modo cor non habere, sed ne palatum quidem. Quantam rem agas, ut Circeis qui habitet totum hunc mundum suum municipium esse existimet? Huius, Lyco, oratione locuples, rebus ipsis ielunior. Sed quid attinet de rebus tam apertis plura requirere? Non quam nostram quidem, inquit Pomponius iocans; Alterum significari idem, ut si diceretur, officia media omnia aut pleraque servantem vivere. Stoici scilicet" = "Duo Reges: constructio interrete. Qui autem esse poteris, nisi te amor ipse ceperit? Hoc est non modo cor non habere, sed ne palatum quidem. Quantam rem agas, ut Circeis qui habitet totum hunc mundum suum municipium esse existimet? Huius, Lyco, oratione locuples, rebus ipsis ielunior. Sed quid attinet de rebus tam apertis plura requirere? Non quam nostram quidem, inquit Pomponius iocans; Alterum significari idem, ut si diceretur, officia media omnia aut pleraque servantem vivere. Stoici scilicet"

Const Bucket

Bucket: string = configuration.Bucket

Const Bucket

Bucket: string = configuration.Bucket

Const Bucket

Bucket: string = configuration.Bucket

Const Bucket

Bucket: string = configuration.Bucket

Const Key

Key: string = configuration.Key

Const MIN_PART_SIZE

MIN_PART_SIZE: number = 1024 * 1024 * 5

Const fakeStreamOfUnknownlength

fakeStreamOfUnknownlength: ReadableStream<any> = new ReadableStream({start: async (controller) => {for (let index = 0; index < 8; index++) {const time = Math.random() * 5;await sleep(time);console.log(`Delaying part ${index} for ${time}`);controller.enqueue(`[part ${index}] with ${"#".repeat(2000000)}`);}controller.close();},})

Const fakeStreamOfUnknownlength

fakeStreamOfUnknownlength: Readable = Readable.from(generateContents())

Const fileStream

fileStream: ReadStream = fs.createReadStream(__dirname + "/big.file")

Const idPool

idPool: "us-west-2:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" = "us-west-2:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"

Const region

region: "us-west-2" = "us-west-2"

Const region

region: "us-west-2" = "us-west-2"

Const region

region: "us-west-2" = "us-west-2"

Functions

Const byteLength

  • byteLength(input: any): any

generateContents

  • generateContents(): AsyncGenerator<string, void, unknown>

generateContents

  • generateContents(): AsyncGenerator<string, void, unknown>

Const getChunk

getChunkBuffer

  • getChunkBuffer(data: Buffer, partSize: number): AsyncGenerator<RawDataPart, void, undefined>

getChunkStream

  • getChunkStream<T>(data: T, partSize: number, getNextData: (data: T) => AsyncGenerator<Buffer>): AsyncGenerator<RawDataPart, void, undefined>
  • Type parameters

    • T

    Parameters

    • data: T
    • partSize: number
    • getNextData: (data: T) => AsyncGenerator<Buffer>
        • (data: T): AsyncGenerator<Buffer>
        • Parameters

          • data: T

          Returns AsyncGenerator<Buffer>

    Returns AsyncGenerator<RawDataPart, void, undefined>

getDataReadable

  • getDataReadable(data: Readable): AsyncGenerator<Buffer>

getDataReadableStream

  • getDataReadableStream(data: ReadableStream): AsyncGenerator<Buffer>

Const sleep

  • sleep(seconds: number): Promise<unknown>

Const sleep

  • sleep(seconds: number): Promise<unknown>

Const sleep

  • sleep(seconds: number): Promise<unknown>

Const uploadIndeterminateLengthStreamBrowser

  • uploadIndeterminateLengthStreamBrowser(): Promise<void>

Const uploadIndeterminateLengthStreamNode

  • uploadIndeterminateLengthStreamNode(): Promise<void>

Const uploadIndeterminateLengthStreamNode

  • uploadIndeterminateLengthStreamNode(): Promise<void>

Object literals

Const ClientDefaultValues

ClientDefaultValues: object
internal

lstatSync

lstatSync: lstatSync

runtime

runtime: string = "node"

Const ClientDefaultValues

ClientDefaultValues: object
internal

runtime

runtime: string = "browser"

Const ClientDefaultValues

ClientDefaultValues: object
internal

runtime

runtime: string = "react-native"

Const ClientSharedValues

ClientSharedValues: object
internal

lstatSync

  • lstatSync(): void

Const configuration

configuration: object

Bucket

Bucket: string = "test-bucket-1234567890"

Key

Key: string = `unique-key-${Date.now}`