Skip to content

Upload large files with tus

By , Head of IntegrationsUpdated

Open this page in a new chat

Short answer

This page has 2 commands: List available tus.io locations (GET /v2/files/tus/locations) and Get tus.io upload link (GET /v2/files/tus/url). Each call needs a bearer token and counts towards your hourly API limit. Below are the parameters, sample code in 9 languages and a sample answer.

After reading this you will know

  • How to upload large files with tus
  • Which parameters each of the 2 commands takes
  • Sample code in 9 languages and a sample answer

Every command on this page needs a bearer token and counts towards your hourly limit.

GEThttps://api.sirv.com/v2/files/tus/locations

Use this API method to list available tus.io locations.

Each location is an upload server near one city. Pick the one closest to you, then ask for an upload link with Get tus.io upload link. How tus.io uploads work is explained in tus.io multipart uploads.

Example request

// Your bearer token, from POST /v2/token, in the SIRV_TOKEN environment variable
const res = await fetch('https://api.sirv.com/v2/files/tus/locations', {
method: 'GET',
headers: { authorization: `Bearer ${process.env.SIRV_TOKEN}` },
});
console.log(res.status, await res.text());

Example response

[
"au_sydney",
"br_sao_paulo",
"ca_monreal",
"de_falkenstein",
"fi_helsinki",
"fr_paris",
"gb_london",
"hk_hong_kong",
"in_mumbai",
"kr_seoul",
"nz_christchurch",
"sg_singapore",
"us_atlanta",
"us_buffalo",
"us_chicago",
"us_dallas",
"us_kansas",
"us_los_angeles",
"us_miami",
"us_phoenix",
"us_seattle",
"us_washington",
"za_capetown"
]
GEThttps://api.sirv.com/v2/files/tus/url

Use this API method to get a link for uploading a file with tus.io.

tus.io uploads send a file in chunks of up to 1 MB, can resume after a broken connection and take files up to 1 GB. The link works for 1 hour unless you set expiresIn, up to 7 days.

Use the link as the endpoint of a tus.io client and give the file’s path in metadata.filename. The file shows in your account 1 to 4 seconds after the upload ends. The steps are in tus.io multipart uploads.

Query parameters

NameTypeRequiredExampleDescription
locationstringYesgb_londonUpload server to send the file to, from List available tus.io locations.
expiresInnumberNo18000URL expiration time in seconds

Example request

// Your bearer token, from POST /v2/token, in the SIRV_TOKEN environment variable
const res = await fetch('https://api.sirv.com/v2/files/tus/url?location=gb_london&expiresIn=18000', {
method: 'GET',
headers: { authorization: `Bearer ${process.env.SIRV_TOKEN}` },
});
console.log(res.status, await res.text());

Example response

{
"url": "https://sirvcdn-gbr-4.sirv.com:444/upload/eyJhbhoaigGSiuhgkahFFGnX0"
}
Back to top