dimah-s3v1.5.5

Multipart Hooks

Large-file multipart upload lifecycle, part authorization, and assembly.

Enable multipart support on large-file routes by setting upload.multipart: true or passing a MultipartConfig object.

lib/s3.ts
import { S3Client } from "@aws-sdk/client-s3";
import { dimahS3, route } from "@dimah-s3/server";

export const awsS3 = new S3Client({/* env */});

export const s3 = dimahS3({
  client: awsS3,
  bucket: process.env.S3_BUCKET!,
  routes: {
    video: route({
      upload: {
        fileTypes: ["video/*"],
        maxFileSize: 500 * 1024 * 1024, // 500MB
        multipart: true,
        onConfirmed: async ({ key, contentLength }) => {
          // Triggered on successful multipart completion
        },
      },
    }),
  },
});

Multipart lifecycle flow

Multipart upload flow
  1. upload.guardInit validation
  2. CreateMultipartUploadS3
  3. multipart.guardAuthorizes each part
  4. CompleteMultipartUploadS3
  5. HeadObjectserver
  6. onConfirmedFinal metadata

Type reference

import type {
  MultipartConfig,
  MultipartOnInitContext,
  MultipartGuardContext,
  MultipartOnAbortContext,
  MultipartOnListContext,
} from "@dimah-s3/server";

MultipartConfig

Prop

Type


MultipartOnInitContext

Prop

Type


MultipartGuardContext

Prop

Type


MultipartOnAbortContext

Prop

Type


MultipartOnListContext

Prop

Type

Frequently asked questions

On this page