Uppy File Uploader Uppy File Uploader

Uppy is an open source file uploader for web browsers by Transloadit. With over 29,000 stargazers on GitHub it is the #1 file uploader in the world. Uploads can survive network hiccups, browser crashes, and accidental navigate-aways thanks to Tus support built-in, and it is the recommended way to integrate Transloadit with web browsers.

The Transloadit plugin for Uppy helps you talk to the Transloadit API. It can be used with all the other Uppy plugins, for example the modal UI file picker with support for imports from third-party services like Instagram, integration with HTML forms, and more.

Transloadit hosts the required server components (Companion and Tusd) for you, as well as of course our encoding API.

Example

For demo purposes, we'll just show one happy path, of using Transloadit's face detection in combination with a picker, and we'll be using our CDN bundle for easy copy-pastability. Make sure to replace YOUR_TRANSLOADIT_KEY with your Transloadit API Key.

<!-- This pulls Uppy from our CDN -->
<!-- For smaller self-hosted bundles, install Uppy and plugins manually: -->
<!-- npm i --save @uppy/core @uppy/dashboard @uppy/remote-sources @uppy/transloadit ... -->
<link
  href="https://releases.transloadit.com/uppy/v4.3.0/uppy.min.css"
  rel="stylesheet"
/>
<button id="browse">Select Files</button>
<script type="module">
  import {
    Uppy,
    Dashboard,
    ImageEditor,
    RemoteSources,
    Transloadit,
  } from 'https://releases.transloadit.com/uppy/v4.3.0/uppy.min.mjs'
  const uppy = new Uppy()
    .use(Transloadit, {
      waitForEncoding: true,
      alwaysRunAssembly: true,
      assemblyOptions: {
        params: {
          // To avoid tampering, use Signature Authentication:
          // https://transloadit.com/docs/topics/signature-authentication/
          auth: {
            key: 'YOUR_TRANSLOADIT_KEY',
          },
          // It's often better store encoding instructions in your account
          // and use a template_id instead of adding these steps inline
          steps: {
            ':original': {
              robot: '/upload/handle',
            },
            faces_detected: {
              use: ':original',
              robot: '/image/facedetect',
              crop: true,
              faces: 'max-confidence',
              format: 'preserve',
              crop_padding: '10%',
            },
            exported: {
              use: ['faces_detected', ':original'],
              robot: '/s3/store',
              credentials: 'YOUR_AWS_CREDENTIALS',
              url_prefix: 'https://demos.transloadit.com/',
            },
          },
        },
      },
    })
    .use(Dashboard, { trigger: '#browse' })
    .use(ImageEditor, { target: Dashboard })
    .use(RemoteSources, {
      companionUrl: 'https://api2.transloadit.com/companion',
    })
    .on('complete', ({ transloadit }) => {
      // Due to waitForEncoding:true this is fired after encoding is done.
      // Alternatively, set waitForEncoding to false and provide a notify_url
      console.log(transloadit) // Array of Assembly Statuses
      transloadit.forEach((assembly) => {
        console.log(assembly.results) // Array of all encoding results
      })
    })
    .on('error', (error) => {
      console.error(error)
    })
</script>

For more examples, take a look at examples/, or try them live. Uppy and Transloadit are very versatile so you may have a different need, and likely, we already support it.

Documentation

See the full documentation for Uppy's Transloadit Plugin, which is the recommended way to integrate Transloadit and Uppy.

Related blog posts