Skip to content

Uploading & decoding

Upload: Media File, Alignment File or both

In order to upload a media file a TUS client is needed. The TUS protocol is a standard for resumable uploads. The TUS client is responsible for the upload of the file and the Scriptix API is responsible for the processing of the file. The TUS client needs to be configured to use the following URL:

Developing your own TUS client?

You can find the TUS protocol specification at https://tus.io/protocols/resumable-upload.html.

URL for TUS client: https://api.scriptix.io/api/v3/files/

Request headers

Only one of the headers need to be present depending on the type of Authorization you have at hand.

Parameter Value Description
Authorization Bearer *Scriptix Batch API Token* API key needed for authorization. Or
x-zoom-s2t-key *Scriptix Batch API Token* API key of type batch needed for authorization

Working example

using a Python TUS client https://github.com/tus/tus-py-client, while the principle applies to all other language clients.

from tusclient import client

my_client = client.TusClient('https://api.scriptix.io/api/v3/files/',
                              headers={'Authorization': 'Bearer e....Pj6YZkZ48....'})
uploader = my_client.uploader(
    "/path/to/videos/test.mp4",
    metadata={
        'language': 'en-US',
        'document_type': 'caption',
        'filetype': 'audio/mp4',
        'filename': 'test.mp4',
        'punctuation': 'true',
        'keep_source': 'true',
        'multichannel': 'false',
        'document': "{ \"webhook_headers\": [\"Custom-Header-Name: Header Value\"], \"webhook_method\": \"POST\", \"webhook_url\": \"https://example.com/webhook\", ... }"
    })

uploader.upload()

we use UPPY as TUS client https://uppy.io/docs/tus/, but you can use other libraries as well. The following example shows how to upload a file with UPPY:

import Tus from '@uppy/tus'

const uppy = new Uppy({
    restrictions: {
        allowedFileTypes: ['video/*', 'audio/*'] | ['video/*', 'audio/*', 'text/*'], // if alignment | linked is the purpose, text files are allowed
        maxTotalFileSize: 10737418240 /* 10GB */, // 10GB
        minNumberOfFiles: 'alignment' ? 2 : null, // if alignment is selected, only 2 files are allowed
        maxNumberOfFiles: 'alignment' ? 2 : null, // if alignment is selected, only 2 files are allowed
    }
})
    .use(DropTarget, { target: document.body });

// chained or later you can use TUS
uppy.use(Tus, {
  endpoint: 'https://api.scriptix.io/api/v3/files/', // tus endpoint here
  retryDelays: [0, 1000, 3000, 5000], 
  headers: {
    'Authorization': `Bearer ${ bearerToken }`, 
    // Optionally if you do not set meta as below, you can set it in the headers like this:
    // "Upload-Metadata": `language ${base64_encode('en-US')}, document_type ${base64_encode('document')}, linked ${base64_encode('false')}, punctuation ${base64_encode('false')}, keep_source ${base64_encode('false')}, multichannel ${base64_encode('false')}, uuid ${base64_encode(uuidv4())}`
  },
  withCredentials: true,
})

// depending on the logic you should also include the following code to upload metadata in headers.
// Additionally, you can add metadata in the headers above.
uppy.setMeta({
    language: 'nl-nl', // REQUIRED (e.g. 'en-US')
    document_type: 'document' | 'caption', // REQUIRED. Only send 'caption' or 'document' as value
    session_id: 'xyz' | '-1' | undefined, // OPTIONAL (Do not set this field) ONLY IF YOU HAVE INITIALIZED SESSION EARLIER WITH NO DOCUMENTS (it is managed automatically). DEFAULT VALUE IS -1
    punctuation: 'punctuation' ? 'true' : 'false', // OPTIONAL. DEFAULT VALUE IS false
    keep_source: 'keepSource' | 'keepMedia' ? 'true' : 'false', // OPTIONAL. DEFAULT VALUE IS false
    multichannel: 'multichannel' ? 'true' : 'false', // OPTIONAL. DEFAULT VALUE IS false
    document: "{ 'name': 'test.mp4', 'type': 'video/mp4' }", // OPTIONAL. Stringified JSON object. You can pass webhooks and other properties here as well. DEFAULT VALUE IS undefined
})

// later in UI you can add the following code to upload the file (example in React)
<Dashboard
    uppy={ uppy }
    target={ '#drag-drop-area' }
/>

Using other TUS clients?

Additionally, you can use other TUS libraries like tus-js-client or in python tus-py-client, and other languages as well. For more information about TUS, please visit https://tus.io/implementations.html.