Custom upload strategy

Custom strategy via AjaxUploader.registerStrategy()

Built-in strategies (single / chunked / s3 / azure / tus / urlImport) cover the common transports. For everything else — signed-GCS multipart, a custom protocol against a legacy backend, WebRTC-style peer upload — register your own strategy. A strategy is just an object with an upload(task, uploader) method that returns a Promise.

Strategy contract
AjaxUploader.registerStrategy('my-transport', {
    upload: function (task, uploader) {
        // Must honour task.abortController for cancel + pause.
        // Must call uploader._updateProgress(task, loaded, total) to advance UI.
        // Must resolve with an UploadResult-shaped object, or reject.

        return fetch('/my-endpoint', {
            method: 'POST',
            body: task.file,
            signal: task.abortController.signal
        }).then(function (r) {
            return r.json();
        });
    },
    name: 'my-transport'            // shown in task.metadata.strategy
});

// Use it:
AjaxUploader.create('#uploader', { strategy: 'my-transport' });
When to roll your own
  • Your backend expects a protocol AjaxUploader doesn't ship (GCS resumable, custom chunk headers, long-polling).
  • You need to inject auth-rotation, signed headers per request, or custom retry semantics.
  • You want to wrap an existing SDK (AWS SDK v3, Uppy's internal uploader) with AjaxUploader's UI + progress model.
  • You need WebRTC / peer upload / P2P transport.
Inline strategy objects

You can also pass a strategy object directly — no registry call needed:

AjaxUploader.create('#uploader', {
    strategy: { name: 'inline', upload: function (task, uploader) { /* ... */ } }
});