Documentation

Guides and API reference for uploads, image transforms and video.

npm install @cd2/fileboy-react
API https://api.fileboy.io

Large and resumable uploads

Send big files in parts. A dropped connection costs one part, not the whole upload, and an upload can carry on after a crash or a reload.

When to use it

POST /files/upload sends a file in one request. That is the simplest way for most files, but a long upload on a phone or a hotel network that drops at 90% starts again from nothing. Upload sessions split the file into parts (8 MiB to 64 MiB, Fileboy chooses) and send each one on its own:

  • A part that fails is retried by itself, with backoff.
  • Several parts go at once, which is faster on most connections.
  • The session remembers which parts storage has, so an upload stopped by a crash, a closed tab or a lost connection carries on from there.
  • Parts go through Fileboy's API, or straight to storage on presigned URLs where direct uploads are turned on for Fileboy's storage. The session's direct says which. Either way you PUT each part to the URL you are given.

The libraries switch to sessions for files of 50 MiB and up when you turn on resumable. The Python library's upload_file and upload_video do it for every file on disk of that size, as building the request in memory otherwise would hold the whole file. The file you end up with is the same as an upload's: the same checks, type detection, hash, image data, folder, metadata, webhooks and activity log.

From the libraries

Upload in parts
// Files of 50 MiB and up go in parts. Choosing the same file again after a
// reload carries on from the parts already sent.
<MultiFileUploader resumable onFilesUploaded={files => save(files)} />

// Your own UI, with pause and resume
const upload = fileboy.createResumableUpload(file, {
  folderPath: "/films",
  concurrency: 4,
  onProgress: ({ loaded, total }) => setPercent((loaded / total) * 100),
})
pauseButton.onclick = () => (upload.paused ? upload.resume() : upload.pause())
const { file: saved } = await upload.start()

The browser libraries keep the session id in localStorage, keyed by the file's name, size and date (and whether it is a video), so picking the same file again on the same site resumes it, as long as it goes to the same folder with the same name and metadata. The server libraries give you the session as soon as it is made (onSession in Node and PHP, on_session in Python and Ruby): keep its id and pass it back to carry on.

1. Start a session

POST /uploads takes the file's size in bytes, its filename and mime, and what a normal upload takes: name, metadata, and folderId or folderPath. Send "kind": "video" (with description, tags and source) to make a video, as POST /videos/upload does.

It takes the same keys as an upload: the public key (held to your allowed origins), an upload token, your private key, or a scoped key with the uploads scope. A session started with a signed request can only be continued with one.

1
2
3
4
5
6
7
curl -X POST https://api.fileboy.io/uploads -H 'Authorization: public YOUR_PUBLIC_KEY' -H 'Content-Type: application/json' -d '{
    "filename": "launch.mov",
    "size": 2147483648,
    "mime": "video/quicktime",
    "folderPath": "/films",
    "metadata": { "project": "launch" }
  }'
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
HTTP/1.1 201 Created

{
  "data": {
    "id": "5f0c3b1e-8a2d-4c6e-9f1a-2b3c4d5e6f70",
    "status": "open",
    "kind": "file",
    "name": "launch.mov",
    "size": 2147483648,
    "partSize": 8388608,
    "partCount": 256,
    "direct": true,
    "expiresAt": "2026-11-19T10:00:00Z",
    "parts": [],
    "uploadedBytes": 0,
    "file": null,
    "video": null
  }
}

Every part is partSize bytes except the last, which has what is left. Part n is the bytes from (n - 1) × partSize.

2. Send the parts

Ask for part URLs a batch at a time (up to 100) with POST /uploads/{id}/parts, then PUT each part's bytes to its URL with its headers and no key: the URL is the permission, for that one part, for 15 minutes. Ask again for a URL that expired. Keep the ETag header each PUT answers with.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
curl -X POST https://api.fileboy.io/uploads/5f0c3b1e-8a2d-4c6e-9f1a-2b3c4d5e6f70/parts -H 'Authorization: public YOUR_PUBLIC_KEY' -H 'Content-Type: application/json' -d '{ "parts": [1, 2, 3, 4] }'

{
  "data": {
    "direct": true,
    "parts": [
      {
        "number": 1,
        "size": 8388608,
        "url": "https://storage.example/...&partNumber=1&uploadId=...&X-Amz-Signature=...",
        "method": "PUT",
        "headers": {},
        "expiresAt": "2026-11-18T10:15:00Z"
      }
    ]
  }
}

# Then PUT each part's bytes to its URL, with no Authorization header
curl -X PUT --data-binary @part-1.bin '<url>'   # answers with an ETag header

Parts can go in any order and several at once. Sending a part again replaces it. A part must be exactly its size. Sent through Fileboy's API, one that isn't is refused at the PUT; sent straight to storage, it is caught at complete.

3. Resume

GET /uploads/{id} answers with the session and the parts storage already has (their numbers, sizes and ETags) and uploadedBytes. Send the rest, then complete. Sessions last 24 hours; after that the parts are thrown away and the session is gone (404 upload_not_found), so start again.

4. Complete

POST /uploads/{id}/complete checks storage has every part at its size (and, if you send them, that the ETags match), puts them together, and saves the file exactly as an upload would. Fileboy reads the stored file once, start to end: its type comes from its first bytes, not its name, its SHA-1 hash from every byte, and an image gets its size, EXIF data and palette. Fileboy works out the hash itself rather than trusting one sent with the upload, because hash is what finding duplicates relies on.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
curl -X POST https://api.fileboy.io/uploads/5f0c3b1e-8a2d-4c6e-9f1a-2b3c4d5e6f70/complete -H 'Authorization: public YOUR_PUBLIC_KEY' -H 'Content-Type: application/json' -d '{ "parts": [{ "number": 1, "etag": "\"9b2cf535f27731c974343645a3985328\"" }] }'

{
  "data": {
    "id": "5f0c3b1e-8a2d-4c6e-9f1a-2b3c4d5e6f70",
    "status": "completed",
    "file": {
      "id": "2a860257-ecf9-424a-846e-00ab68e2fd58",
      "name": "launch.mov",
      "mime": "video/quicktime",
      "fileSize": 2147483648,
      "hash": "2fd4e1c67a2d28fced849ee1bb76e7391b93eb12",
      "folderPath": "/films",
      ...
    },
    "video": null
  }
}

Then the file goes in its folder, file.uploaded is sent to your webhooks, and the activity log records it. A video session makes the video, sends video.uploaded and starts processing. Completing a big file takes a few seconds per gigabyte. If the answer is lost, complete again: a completed session answers with the same file and makes no other.

DELETE /uploads/{id} stops a session and throws its parts away. On a completed session it removes only the session, never the file.

Open-ended sessions

For a file that is still being made, such as a recording uploaded while it records, start the session with openEnded: true and no size. <fileboy-recorder> does this for you (see the recorder).

1
2
3
4
5
6
7
curl -X POST https://api.fileboy.io/uploads -H 'Authorization: public YOUR_PUBLIC_KEY' -H 'Content-Type: application/json' -d '{ "kind": "video", "openEnded": true, "filename": "Recording.webm",
        "mime": "video/webm", "source": "recording" }'
# { "data": { "id": "...", "openEnded": true, "size": null, "partSize": 5242880,
#             "videoId": "8c1d...", "maxSize": 5368709120, ... } }

# Each full part as it is ready, then the last one with its size
curl -X POST https://api.fileboy.io/uploads/<id>/parts -H 'Authorization: public YOUR_PUBLIC_KEY' -H 'Content-Type: application/json' -d '{ "parts": [{ "number": 7, "size": 1048576 }] }'

Every part is partSize (5 MiB, the smallest storage takes) except the last, which may be smaller. Send each part as soon as it is full; when the file is finished, ask for the last part's URL with its size, send it and complete. The file's size is what the parts add up to. size and partCount are null until then.

The limits are checked as the parts come. The session reserves one part when it starts, and each call for part URLs grows what it reserves to the end of its furthest part: past your plan's upload cap (maxSize) is 413 file_too_large, past your storage limit 403 storage_limit_reached. Both are checked again at complete. A session that is never completed expires after 24 hours like any other, and its parts are thrown away.

A video session (open-ended or not) reserves its video's id when it starts: videoId. Its watch and embed links work at once, showing "still uploading", and GET /videos/{id}/data answers uploading: true until the session completes. The video is only made then, so it only counts toward your video allowance, and video.uploaded is only sent, once it is complete. An aborted or expired session takes its id with it.

Limits

  • The declared size is held to your plan's upload cap, the same cap as a single upload, when the session starts. The stored file must be that size exactly.
  • While a session is open its size counts against the app's storage limit and it counts as one file against the file limit, so uploads running at once can't take the app past either. Both are checked again at complete.
  • Up to 10,000 parts, 1,000 open signed sessions and 200 public-key ones per app, and part URLs that last 15 minutes. Starting sessions is rate limited per app, and per address for the public key.
  • The shared demo app takes images only, up to its own small cap, and no video.
Uploads are still capped by your plan: sessions make big files reliable, not bigger than the plan allows. See storage.

Errors

StatuserrorWhat it means
413file_too_largeThe declared size is over your plan's upload cap.
403storage_limit_reachedThe file would take the app past its storage limit, counting the uploads in progress. Checked when the session is made and again at complete.
403limit_reachedThe app is at its file limit, counting the uploads in progress as files.
429too_many_uploadsThe app has 1,000 signed sessions open, or 200 made with the public key. Complete or abort some.
429rate_limitedToo many sessions were started in the last hour.
404upload_not_foundNo session with that id, or it expired (sessions last 24 hours).
403invalid_part_urlA part URL that points at Fileboy was changed or has expired.
409upload_not_openThe session is completing or completed and takes no more parts.
409parts_missingComplete was asked for before storage had every part. It lists them.
409part_size_mismatchA part in storage is not the size it should be. Send it again.
409part_mismatchA part's ETag is not the one you sent. Send it again.
409upload_completingAnother request is completing this session. Ask again shortly.
422size_mismatchThe file stored is not the declared size. The session and its parts are thrown away.
415file_type_not_allowedThe shared demo app only takes images, checked against the file's bytes at complete.

Related guides