Skip to main content
Search...

Strategies Overview

Pluggable upload strategies for different backends and protocols.

Strategies implement the upload protocol and are registered with the core engine. The engine selects the correct strategy based on the strategy field in the intent returned by your backend.

Responsibilities

Each strategy is responsible for:

  • Translating an intent into network calls
  • Reporting progress and persisting cursor updates
  • Honoring abort signals for pause and cancel

Available Strategies

StrategyUse CaseResumable
POSTSimple presigned form uploadsNo
MultipartLarge file uploads with concurrent partsYes

Registry

Use the registry helper to install strategies before creating the store:

import { createStrategyRegistry, PostStrategy, multipartStrategy } from '@gentleduck/upload/strategies'
 
const registry = createStrategyRegistry()
registry.set(PostStrategy())
registry.set(multipartStrategy())
import { createStrategyRegistry, PostStrategy, multipartStrategy } from '@gentleduck/upload/strategies'
 
const registry = createStrategyRegistry()
registry.set(PostStrategy())
registry.set(multipartStrategy())

The registry enforces typed strategy keys via the intent map, ensuring type safety between your backend's intent response and the strategy implementation.

See Strategy Registry for more details.