Skip to content
ViralSyncViralSync Docs
API

Uploading media

Reserve an upload, send the file straight to storage and complete it, for small and large files.

Media is uploaded in three steps: reserve, send, complete. The file itself goes straight to storage through a presigned URL, never through the API. All three steps need the assets.write scope.

What can be uploaded

KindContent types
Videovideo/mp4, video/quicktime, video/webm
Imageimage/jpeg, image/png, image/webp

One file can be up to 5 GB.

1. Reserve

curl -X POST $B/assets -H "$H" -H 'Content-Type: application/json' \
  -d '{"filename":"clip.mp4","contentType":"video/mp4","sizeBytes":1048576}'

The answer holds the new asset, with the status pending, and an upload plan. The plan has one of two shapes.

A single upload
{
  "asset": { "id": "as_…", "status": "pending" },
  "upload": { "method": "single", "url": "https://…", "contentType": "video/mp4" }
}
A multipart upload
{
  "asset": { "id": "as_…", "status": "pending" },
  "upload": {
    "method": "multipart",
    "partSize": 16777216,
    "partCount": 3,
    "parts": [
      { "partNumber": 1, "url": "https://…" },
      { "partNumber": 2, "url": "https://…" },
      { "partNumber": 3, "url": "https://…" }
    ]
  }
}

The asset fields are shortened here, and the part size is an example. Read method and follow the plan you get; do not assume one from the file size.

2. Send the file

For a single upload, send the whole file with PUT and the content type from the plan:

curl -X PUT "$UPLOAD_URL" -H 'Content-Type: video/mp4' --data-binary @clip.mp4

For a multipart upload, cut the file into pieces of partSize bytes and PUT each piece to the URL with its partNumber. The last piece is whatever remains.

If an upload is interrupted, ask for fresh URLs for the parts that are still missing:

curl -X POST $B/assets/$ASSET/upload -H "$H" -H 'Content-Type: application/json' -d '{}'

3. Complete

curl -X POST $B/assets/$ASSET/complete -H "$H" -H 'Content-Type: application/json' -d '{}'

ViralSync checks the stored file and answers with the asset, now ready. Only a ready asset can be attached to a post. The body may carry width, height and durationMs if your script knows them.

Limits

Reserving an upload counts against the plan's storage and its monthly upload volume. When either is used up, the request answers 409 with the code storage_limit_reached or upload_limit_reached. See Errors and limits.