remote-sources.mdx 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. ---
  2. sidebar_position: 1
  3. slug: /remote-sources
  4. ---
  5. import Tabs from '@theme/Tabs';
  6. import TabItem from '@theme/TabItem';
  7. import UppyCdnExample from '/src/components/UppyCdnExample';
  8. # Remote sources
  9. `@uppy/remote-sources` is a preset plugin (meaning it bundles and sets up other
  10. plugins) to add all the available remote sources, such Instagram, Google Drive,
  11. Dropbox, and others to Uppy Dashboard in one package.
  12. :::note
  13. Remote Sources requires Dashboard and automatically installs all its plugins to
  14. it.
  15. :::
  16. ## When should I use it?
  17. `@uppy/remote-sources` aims to simplify the setup for adding Companion plugins,
  18. when you want to share the configuration between plugins. If you want your users
  19. to upload files from any of the remote sources that Uppy offers, this plugin is
  20. recommended.
  21. A [Companion](/docs/companion) instance is required for the Remote Sources
  22. plugin to work. Companion handles authentication with the remote services (such
  23. as Facebook, Dropbox, etc.), downloads the files, and uploads them to the
  24. destination. This saves the user bandwidth, especially helpful if they are on a
  25. mobile connection.
  26. You can self-host Companion or get a hosted version with any
  27. [Transloadit plan](https://transloadit.com/pricing/).
  28. ## Install
  29. <Tabs>
  30. <TabItem value="npm" label="NPM" default>
  31. ```shell
  32. npm install @uppy/remote-sources
  33. ```
  34. </TabItem>
  35. <TabItem value="yarn" label="Yarn">
  36. ```shell
  37. yarn add @uppy/remote-sources
  38. ```
  39. </TabItem>
  40. <TabItem value="cdn" label="CDN">
  41. <UppyCdnExample>
  42. {`
  43. import { RemoteSources } from "{{UPPY_JS_URL}}"
  44. const RemoteSources = new Uppy().use(RemoteSources)
  45. `}
  46. </UppyCdnExample>
  47. </TabItem>
  48. </Tabs>
  49. ## Use
  50. ```js {10} showLineNumbers
  51. import Uppy from '@uppy/core';
  52. import Dashboard from '@uppy/dashboard';
  53. import RemoteSources from '@uppy/remote-sources';
  54. import '@uppy/core/dist/style.min.css';
  55. import '@uppy/dashboard/dist/style.min.css';
  56. new Uppy();
  57. .use(Dashboard);
  58. .use(RemoteSources, { companionUrl: 'https://your-companion-url' });
  59. ```
  60. ## API
  61. ### Options
  62. #### `id`
  63. A unique identifier for this plugin (`string`, default: `RemoteSources`).
  64. #### `sources`
  65. List of remote sources that will be enabled (`array`, default:
  66. `['Box', 'Dropbox', 'Facebook', 'GoogleDrive','Instagram', 'OneDrive', 'Unsplash', 'Url', 'Zoom']`).
  67. You don’t need to specify them manually or change them, but if you want to alter
  68. the order in which they appear in the Dashboard, or disable some sources, this
  69. option is for you.
  70. ```js
  71. uppy.use(RemoteSources, {
  72. companionUrl: 'https://your-companion-url',
  73. sources: ['Instagram', 'GoogleDrive', 'Unsplash', 'Url'],
  74. });
  75. ```
  76. #### `companionUrl`
  77. URL to a [Companion](/docs/companion) instance (`string`, default: `null`).
  78. #### `companionHeaders`
  79. Custom headers that should be sent along to [Companion](/docs/companion) on
  80. every request (`object`, default: `{}`).
  81. #### `companionAllowedHosts`
  82. The valid and authorized URL(s)/URL pattern(s) from which OAuth responses should
  83. be accepted (`string | RegExp | Array<string | RegExp>`, Default:
  84. `companionUrl`).
  85. This value can be a `string`, a `RegExp` object, or an array of both.
  86. This is useful when you have your [Companion](/docs/companion) running on
  87. several hosts. Otherwise, the default value, which is `companionUrl`, should do
  88. fine.
  89. #### `companionCookiesRule`
  90. This option correlates to the [`Request.credentials` value][], which tells the
  91. plugin whether to send cookies to [Companion](/docs/companion) (`string`,
  92. default: `same-origin`).
  93. #### `target`
  94. DOM element, CSS selector, or plugin to place the drag and drop area into
  95. (`string`, `Element`, `Function`, or `UIPlugin`, default: `Dashboard`).
  96. [`request.credentials` value]:
  97. https://developer.mozilla.org/en-US/docs/Web/API/Request/credentials