# Transloadit

* Useful for large files like videos
* Download, Upload, transcode, and push to an S3/server

## Basics

You create a **template** that has a JSON describing the list of steps or **robots** and their settings

Use the opensource tool [**Uppy**](https://uppy.io/) to upload files, comes with nice upload UI for different sources even GDrive and camera out of the box

Use [Robodog](https://uppy.io/docs/robodog/), the uppy based library to talk to Transloadit API

```javascript
import Robodog from "@uppy/robodog";

const resultPromise = Robodog.upload(files, {
  params: {
    auth: { key: "3.dsafkjads.adsf.afds.adsf.." },
    steps: {
      ":original": {
        robot: "/upload/handle",
      },
      export: {
        use: ":original",
        robot: "/s3/store",
        credentials: "eta-aws",
        //\$ for translodits string stuff url_name is url encoded name with extension
        path: `${new Date().toISOString()}-\${file.url_name}`,
      },
    },
  },
});

resultPromise.then((bundle) => {
  bundle.transloadit // Array of Assembly statuses

})
```

### Templates

Here is a basic template to output .webm

Can use assembly variables like `${fields.*}` if uppy was set to allow it

```javascript
{
  "steps": {
    ":original": {
      "robot": "/upload/handle"
    },
    "filter": {
      "use": ":original",
      "robot": "/file/filter",
      "accepts": [
        [
          "${file.mime}",
          "regex",
          "video"
        ]
      ],
      "error_on_decline": true
    },
    "video_webm": {
      "use": "filter",
      "robot": "/video/encode",
      "ffmpeg_stack": "v3.3.3",
      "preset": "webm"
    },
    "export": {
      "use": [
        "video_webm"
      ],
      "robot": "/s3/store",
      "credentials": "slingshow_aws",
    }
  }
}
```

Then credientials should be set in template credentials


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://openai.gitbook.io/code-cheatsheets/all/apis/transloadit.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
