Remote sources
@uppy/remote-sources is a preset plugin (meaning it bundles and sets up other
plugins) to add all the available remote sources, such as Google Drive, Dropbox,
and others to Uppy Dashboard in one package.
Remote Sources requires Dashboard and automatically installs all its plugins to it.
When should I use it?
@uppy/remote-sources aims to simplify the setup for adding Companion plugins,
when you want to share the configuration between plugins. If you want your users
to upload files from any of the remote sources that Uppy offers, this plugin is
recommended.
A Companion instance is required for the Remote Sources plugin to work. Companion handles authentication with the remote services (such as Facebook, Dropbox, etc.), downloads the files, and uploads them to the destination. This saves the user bandwidth, especially helpful if they are on a mobile connection.
You can self-host Companion or get a hosted version with any Transloadit plan.
Install
- NPM
- Yarn
- CDN
npm install @uppy/remote-sources
yarn add @uppy/remote-sources
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.2.1/uppy.min.css" rel="stylesheet">
<!-- 2. Initialize -->
<div id="uppy"></div>
<script type="module">
import { RemoteSources } from "https://releases.transloadit.com/uppy/v5.2.1/uppy.min.mjs"
const RemoteSources = new Uppy().use(RemoteSources)
</script>
Use
import Uppy from '@uppy/core';
import Dashboard from '@uppy/dashboard';
import RemoteSources from '@uppy/remote-sources';
import '@uppy/core/css/style.min.css';
import '@uppy/dashboard/css/style.min.css';
new Uppy();
.use(Dashboard);
.use(RemoteSources, { companionUrl: 'https://your-companion-url' });
Use with Transloadit
import { COMPANION_URL, COMPANION_ALLOWED_HOSTS } from '@uppy/transloadit';
import RemoteSources from '@uppy/remote-sources';
uppy.use(RemoteSources, {
companionUrl: COMPANION_URL,
companionAllowedHosts: COMPANION_ALLOWED_HOSTS,
});
Transloadit’s shared Google OAuth app is blocked by Google, so the Google Drive
plugin does not work on Transloadit-hosted Companion with the default
credentials. Users get a Google page that says “This app is blocked”. To use
this plugin with hosted Companion you have to register your own Google OAuth app
and hand it to Companion as a Transloadit credential, see
Use with Transloadit. The
Google Drive Picker plugin uses the non-restricted
drive.file scope, so it needs no Google verification, but it still needs your
own Google Cloud client ID, API key and app ID. Background:
Navigating Google’s API changes.
You may also hit rate limits, because the OAuth application is shared between everyone using Transloadit.
To use your own OAuth keys with Transloadit’s hosted Companion servers, create a credential on the Transloadit site (the console calls them Third-party Credentials). Select “Companion OAuth” for the service, pick the provider, and enter the key and secret. Then pass the name of the credential to the matching plugin, keyed by plugin ID, together with your Transloadit API key. The Google Drive page has the full setup for Google.
import { COMPANION_URL, COMPANION_ALLOWED_HOSTS } from '@uppy/transloadit';
import RemoteSources from '@uppy/remote-sources';
uppy.use(RemoteSources, {
companionUrl: COMPANION_URL,
companionAllowedHosts: COMPANION_ALLOWED_HOSTS,
companionKeysParams: {
GoogleDrive: {
key: 'YOUR_TRANSLOADIT_API_KEY',
credentialsName: 'google_drive_own',
},
Dropbox: {
key: 'YOUR_TRANSLOADIT_API_KEY',
credentialsName: 'dropbox_own',
},
// ...etc
},
});
API
Options
id
A unique identifier for this plugin (string, default: RemoteSources).
sources
List of remote sources that will be enabled (array, default:
['Box', 'Dropbox', 'Facebook', 'GoogleDrive', 'OneDrive', 'Unsplash', 'Url', 'Zoom']).
You don’t need to specify them manually or change them, but if you want to alter the order in which they appear in the Dashboard, or disable some sources, this option is for you.
uppy.use(RemoteSources, {
companionUrl: 'https://your-companion-url',
sources: ['Dropbox', 'GoogleDrive', 'Unsplash', 'Url'],
});
companionUrl
URL to a Companion instance (string, default: null).
companionHeaders
Custom headers that should be sent along to Companion on
every request (object, default: {}).
companionAllowedHosts
The valid and authorized URL(s)/URL pattern(s) from which OAuth responses should
be accepted (string | RegExp | Array<string | RegExp>, Default:
companionUrl).
This value can be a string, a RegExp object, or an array of both.
This is useful when you have your Companion running on
several hosts. Otherwise, the default value, which is companionUrl, should do
fine.
companionCookiesRule
This option correlates to the Request.credentials value, which tells the
plugin whether to send cookies to Companion (string,
default: same-origin).
target
DOM element, CSS selector, or plugin to place the drag and drop area into
(string, Element, Function, or UIPlugin, default:
Dashboard).