Transloadit
The @uppy/transloadit plugin can be used to upload files directly to
Transloadit for all kinds of processing, such as
transcoding video, resizing images, zipping/unzipping, and much
more.
When should I use it?
Not sure which uploader is best for you? Read “Choosing the uploader you need”.
Transloadit’s strength is versatility. By doing video, audio, images, documents,
and more, you only need one vendor for all your file processing
needs. The @uppy/transloadit plugin directly uploads to
Transloadit so you don’t have to worry about setting up and maintaining your own
servers, all you have to do is create a Template that
describes what should happen to the uploaded files. Transloadit accepts the
files, processes according to the instructions in the Template, and stores the
results in storage of your choosing, such as a self-owned S3 bucket. The
Transloadit plugin uses Tus under the hood so you don’t have to
sacrifice reliable, resumable uploads.
You should use @uppy/transloadit if you don’t want to host your own Tus or
Companion servers, (optionally) need file processing, and store it in the
service (such as S3 or GCS) of your liking. All with minimal effort.
Install
- NPM
- Yarn
- CDN
npm install @uppy/transloadit
yarn add @uppy/transloadit
The bundle consists of most Uppy plugins, so this method is not recommended for production, as your users will have to download all plugins when you are likely using only a few.
It can be useful to speed up your development environment, so don't hesitate to use it to get you started.
<!-- 1. Add CSS to `<head>` -->
<link href="https://releases.transloadit.com/uppy/v5.1.11/uppy.min.css" rel="stylesheet">
<!-- 2. Initialize -->
<div id="uppy"></div>
<script type="module">
import { Uppy, Transloadit } from "https://releases.transloadit.com/uppy/v5.1.11/uppy.min.mjs"
new Uppy().use(Transloadit, { /* see options */ })
</script>
Use
A quick overview of the complete API.
import Uppy from '@uppy/core';
import Dashboard from '@uppy/dashboard';
import Transloadit from '@uppy/transloadit';
import '@uppy/core/css/style.min.css';
import '@uppy/dashboard/css/style.min.css';
const uppy = new Uppy()
.use(Dashboard, { inline: true, target: 'body' })
.use(Transloadit, {
assemblyOptions: {
params: {
auth: { key: 'your-transloadit-key' },
template_id: 'your-template-id',
},
},
});
// Optionally listen to events
uppy.on('transloadit:assembly-created', (assembly, fileIDs) => {});
uppy.on('transloadit:upload', (file, assembly) => {});
uppy.on('transloadit:assembly-executing', (assembly) => {});
uppy.on('transloadit:result', (stepName, result, assembly) => {});
uppy.on('transloadit:complete', (assembly) => {});
Use with Companion
All Transloadit plans come with a hosted version of Companion.
You can use this plugin together with Transloadit’s hosted Companion service to let your users import files from third party sources across the web. To do so each provider plugin must be configured with Transloadit’s Companion URLs:
import { COMPANION_URL, COMPANION_ALLOWED_HOSTS } from '@uppy/transloadit';
import Dropbox from '@uppy/dropbox';
uppy.use(Dropbox, {
companionUrl: COMPANION_URL,
companionAllowedHosts: COMPANION_ALLOWED_HOSTS,
});
This will already work. Transloadit’s OAuth applications are used to authenticate your users by default. Your users will be asked to provide Transloadit access to their files. Since your users are probably not aware of Transloadit, this may be confusing or decrease trust. You may also hit rate limits, because the OAuth application is shared between everyone using Transloadit.
To solve that, you can use your own OAuth keys with Transloadit’s hosted Companion servers by using Transloadit Template Credentials. Create a Template Credential on the Transloadit site. Select “Companion OAuth” for the service, and enter the key and secret for the provider you want to use. Then you can pass the name of the new credentials to that provider:
import { COMPANION_URL, COMPANION_ALLOWED_HOSTS } from '@uppy/transloadit';
import Dropbox from '@uppy/dropbox';
uppy.use(Dropbox, {
companionUrl: COMPANION_URL,
companionAllowedHosts: COMPANION_ALLOWED_HOSTS,
companionKeysParams: {
key: 'YOUR_TRANSLOADIT_API_KEY',
credentialsName: 'my_companion_dropbox_creds',
},
});