Files

Start a direct upload

Upload a file from your own machine or browser straight to LiveReacting storage. The bytes never pass through the API, so large files work.

  1. Call this endpoint with the file name, type and exact size in bytes.
  2. PUT each part of the file to its URL from parts (no Authorization header; the URL is signed). Part N holds bytes (N-1) * partSize up to N * partSize - 1, and must be exactly parts[].size bytes: storage refuses a part of any other size with 403. You can upload parts in parallel and re-send a part that failed.
  3. Call POST /files/upload/complete with the uploadToken.

Same limits as a Studio upload: the extension must match the type, the size must fit your plan's max file size, and a video upload is refused once your storage is full. Encoding and thumbnails start after completion, as for a Studio upload.

One-part file (up to 256 MiB):

FILE=intro.mp4
SIZE=$(wc -c < "$FILE" | tr -d ' ')
START=$(curl -s -X POST https://api.livereacting.com/v1/external/files/upload \
  -H "Authorization: Bearer $LR_API_KEY" -H "Content-Type: application/json" \
  -d "{\"name\": \"$FILE\", \"type\": \"video\", \"size\": $SIZE}")
# -f fails on an HTTP error, -w prints the status, --speed-* stop a stalled transfer
curl -sS -f -o /dev/null -w 'part 1: %{http_code}\n' --speed-limit 1024 --speed-time 60 \
  -T "$FILE" "$(echo "$START" | jq -r '.parts[0].url')"
curl -X POST https://api.livereacting.com/v1/external/files/upload/complete \
  -H "Authorization: Bearer $LR_API_KEY" -H "Content-Type: application/json" \
  -d "{\"uploadToken\": \"$(echo "$START" | jq -r '.uploadToken')\"}"

Larger file: run the first four lines above (FILE, SIZE, START), then this, then the upload/complete call above. If a part fails, the loop stops: PUT that part again before you complete.

split -b "$(echo "$START" | jq -r '.partSize')" -a 4 "$FILE" part_
i=0
for PART in part_*; do
  URL=$(echo "$START" | jq -r ".parts[$i].url")
  curl -sS -f -o /dev/null -w "part $((i + 1)): %{http_code}\n" --speed-limit 1024 --speed-time 60 \
    -T "$PART" "$URL" || break
  i=$((i + 1))
done

Browser clients: the part URLs point to the storage bucket, not to the API. A web page can upload to them only from an origin the bucket allows; contact us to add yours.

post/files/upload

Request

  • Base URL: https://api.livereacting.com/v1/external
  • URL: https://api.livereacting.com/v1/external/files/upload
  • Auth: HTTP bearer

Request body

namestring required

File name shown in the media library. Its extension must match type:

  • video: .mp4 .m4v .mov .flv .webm .ogv .3gp .wmv .avi .mkv
  • audio: .mp3 .m4a .wav
  • image: .jpg .jpeg .png .gif .bmp .svg .heic .webp
type'video' | 'image' | 'audio' required
sizeinteger required

Exact file size in bytes. It must not exceed your plan's max file size.

folderIdstring nullable

Folder to put the file in. The folder type must match type. Omit for the root.

Example request

{
  "name": "intro.mp4",
  "type": "video",
  "size": 52428800
}

Response

Upload started. Upload the parts, then complete it.

uploadTokenstring

Opaque token. Send it to POST /files/upload/complete after every part is uploaded.

partSizeinteger

Bytes per part. Part N holds bytes (N-1) * partSize up to N * partSize - 1; the last part holds the rest. A file up to 256 MiB has exactly one part.

expiresAtstring date-time

The part URLs and the token stop working at this time (3 days after the start).

Example response

{
  "partSize": 268435456,
  "parts": [
    {
      "partNumber": 1,
      "size": 52428800
    }
  ]
}

Changes

No recorded changes to this operation across all 1 revision of this API.