Skip to main content

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.

note

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 install @uppy/remote-sources

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,
});
Google Drive needs your own Google OAuth app

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).