mirror of
https://github.com/transloadit/uppy.git
synced 2026-08-02 23:03:33 +00:00
refactor: rename host option to serverUrl
This commit is contained in:
parent
0216238b3c
commit
c48c8fcb70
36 changed files with 80 additions and 80 deletions
|
|
@ -33,8 +33,8 @@ const Tus = require('uppy/lib/plugins/Tus')
|
|||
|
||||
const uppy = Uppy({ autoProceed: false })
|
||||
.use(Dashboard, { trigger: '#select-files' })
|
||||
.use(GoogleDrive, { target: Dashboard, host: 'https://server.uppy.io' })
|
||||
.use(Instagram, { target: Dashboard, host: 'https://server.uppy.io' })
|
||||
.use(GoogleDrive, { target: Dashboard, serverUrl: 'https://server.uppy.io' })
|
||||
.use(Instagram, { target: Dashboard, serverUrl: 'https://server.uppy.io' })
|
||||
.use(Webcam, { target: Dashboard })
|
||||
.use(Tus, { endpoint: 'https://master.tus.io/files/' })
|
||||
.on('complete', (result) => {
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ const uppy = Uppy({
|
|||
})
|
||||
|
||||
uppy.use(GoogleDrive, {
|
||||
host: 'http://localhost:3020'
|
||||
serverUrl: 'http://localhost:3020'
|
||||
})
|
||||
uppy.use(Webcam)
|
||||
uppy.use(Dashboard, {
|
||||
|
|
@ -19,5 +19,5 @@ uppy.use(Dashboard, {
|
|||
plugins: ['GoogleDrive', 'Webcam']
|
||||
})
|
||||
uppy.use(AwsS3, {
|
||||
host: 'http://localhost:3020'
|
||||
serverUrl: 'http://localhost:3020'
|
||||
})
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ const options = {
|
|||
region: process.env.UPPYSERVER_AWS_REGION
|
||||
}
|
||||
},
|
||||
server: { host: 'localhost:3020' },
|
||||
server: { serverUrl: 'localhost:3020' },
|
||||
filePath: DATA_DIR,
|
||||
secret: 'blah blah',
|
||||
debug: true
|
||||
|
|
|
|||
|
|
@ -28,8 +28,8 @@ const uppy = Uppy({
|
|||
proudlyDisplayPoweredByUppy: true,
|
||||
note: '2 files, images and video only'
|
||||
})
|
||||
.use(GoogleDrive, { target: Dashboard, host: 'http://localhost:3020' })
|
||||
.use(Instagram, { target: Dashboard, host: 'http://localhost:3020' })
|
||||
.use(GoogleDrive, { target: Dashboard, serverUrl: 'http://localhost:3020' })
|
||||
.use(Instagram, { target: Dashboard, serverUrl: 'http://localhost:3020' })
|
||||
.use(Webcam, { target: Dashboard })
|
||||
.use(Tus, { endpoint: TUS_ENDPOINT })
|
||||
.use(Form, { target: '#upload-form' })
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ module.exports = class MyCustomProvider extends Plugin {
|
|||
// writing out the key explicitly for readability the key used to store
|
||||
// the provider instance must be equal to this.id.
|
||||
this[this.id] = new Provider(uppy, {
|
||||
host: this.opts.host,
|
||||
serverUrl: this.opts.serverUrl,
|
||||
provider: 'mycustomprovider'
|
||||
})
|
||||
|
||||
|
|
|
|||
|
|
@ -10,11 +10,11 @@ const uppy = Uppy({
|
|||
})
|
||||
|
||||
uppy.use(GoogleDrive, {
|
||||
host: 'http://localhost:3020'
|
||||
serverUrl: 'http://localhost:3020'
|
||||
})
|
||||
|
||||
uppy.use(MyCustomProvider, {
|
||||
host: 'http://localhost:3020'
|
||||
serverUrl: 'http://localhost:3020'
|
||||
})
|
||||
|
||||
uppy.use(Dashboard, {
|
||||
|
|
|
|||
|
|
@ -13,4 +13,4 @@ uppy.use(Dashboard, {
|
|||
})
|
||||
|
||||
// No client side changes needed!
|
||||
uppy.use(AwsS3, { host: '/uppy-server' })
|
||||
uppy.use(AwsS3, { serverUrl: '/uppy-server' })
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ app.use('/uppy-server', uppy.app({
|
|||
region: process.env.UPPYSERVER_AWS_REGION
|
||||
}
|
||||
},
|
||||
server: { host: `localhost:${PORT}` }
|
||||
server: { serverUrl: `localhost:${PORT}` }
|
||||
}))
|
||||
|
||||
// Serve the built CSS file.
|
||||
|
|
|
|||
2
examples/react-example/App.js
vendored
2
examples/react-example/App.js
vendored
|
|
@ -20,7 +20,7 @@ module.exports = class App extends React.Component {
|
|||
componentWillMount () {
|
||||
this.uppy = new Uppy({ id: 'uppy1', autoProceed: true, debug: true })
|
||||
.use(Tus, { endpoint: 'https://master.tus.io/files/' })
|
||||
.use(GoogleDrive, { host: 'https://server.uppy.io' })
|
||||
.use(GoogleDrive, { serverUrl: 'https://server.uppy.io' })
|
||||
|
||||
this.uppy2 = new Uppy({ id: 'uppy2', autoProceed: false, debug: true })
|
||||
.use(Tus, { endpoint: 'https://master.tus.io/files/' })
|
||||
|
|
|
|||
|
|
@ -12,8 +12,8 @@
|
|||
<script>
|
||||
const uppy = Uppy.Core({debug: true, autoProceed: false})
|
||||
.use(Uppy.Dashboard, { trigger: '#uppyModalOpener' })
|
||||
.use(Uppy.Instagram, { target: Uppy.Dashboard, host: 'http://localhost:3020' })
|
||||
.use(Uppy.GoogleDrive, { target: Uppy.Dashboard, host: 'http://localhost:3020' })
|
||||
.use(Uppy.Instagram, { target: Uppy.Dashboard, serverUrl: 'http://localhost:3020' })
|
||||
.use(Uppy.GoogleDrive, { target: Uppy.Dashboard, serverUrl: 'http://localhost:3020' })
|
||||
.use(Uppy.Tus, { endpoint: 'https://master.tus.io/files/' })
|
||||
|
||||
uppy.on('success', (fileCount) => {
|
||||
|
|
|
|||
|
|
@ -89,8 +89,8 @@ module.exports = class AwsS3Multipart extends Plugin {
|
|||
}
|
||||
|
||||
assertHost () {
|
||||
if (!this.opts.host) {
|
||||
throw new Error('Expected a `host` option containing an uppy-server address.')
|
||||
if (!this.opts.serverUrl) {
|
||||
throw new Error('Expected a `serverUrl` option containing an uppy-server address.')
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -287,7 +287,7 @@ module.exports = class AwsS3Multipart extends Plugin {
|
|||
connectToServerSocket (file) {
|
||||
return new Promise((resolve, reject) => {
|
||||
const token = file.serverToken
|
||||
const host = getSocketHost(file.remote.host)
|
||||
const host = getSocketHost(file.remote.serverUrl)
|
||||
const socket = new UppySocket({ target: `${host}/api/${token}` })
|
||||
this.uploaderSockets[socket] = socket
|
||||
this.uploaderEvents[file.id] = createEventTracker(this.uppy)
|
||||
|
|
|
|||
|
|
@ -46,13 +46,13 @@ module.exports = class AwsS3 extends Plugin {
|
|||
}
|
||||
|
||||
getUploadParameters (file) {
|
||||
if (!this.opts.host) {
|
||||
throw new Error('Expected a `host` option containing an uppy-server address.')
|
||||
if (!this.opts.serverUrl) {
|
||||
throw new Error('Expected a `serverUrl` option containing an uppy-server address.')
|
||||
}
|
||||
|
||||
const filename = encodeURIComponent(file.name)
|
||||
const type = encodeURIComponent(file.type)
|
||||
return fetch(`${this.opts.host}/s3/params?filename=${filename}&type=${type}`, {
|
||||
return fetch(`${this.opts.serverUrl}/s3/params?filename=${filename}&type=${type}`, {
|
||||
method: 'get',
|
||||
headers: { accept: 'application/json' }
|
||||
}).then((response) => response.json())
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ module.exports = class Dropbox extends Plugin {
|
|||
// writing out the key explicitly for readability the key used to store
|
||||
// the provider instance must be equal to this.id.
|
||||
this[this.id] = new Provider(uppy, {
|
||||
host: this.opts.host,
|
||||
serverUrl: this.opts.serverUrl,
|
||||
provider: 'dropbox'
|
||||
})
|
||||
|
||||
|
|
@ -35,7 +35,7 @@ module.exports = class Dropbox extends Plugin {
|
|||
|
||||
// merge default options with the ones set by user
|
||||
this.opts = Object.assign({}, defaultOptions, opts)
|
||||
this.opts.hostPattern = opts.hostPattern || opts.host
|
||||
this.opts.serverPattern = opts.serverPattern || opts.serverUrl
|
||||
}
|
||||
|
||||
install () {
|
||||
|
|
@ -111,7 +111,7 @@ module.exports = class Dropbox extends Plugin {
|
|||
}
|
||||
|
||||
getItemThumbnailUrl (item) {
|
||||
return `${this.opts.host}/${this.Dropbox.id}/thumbnail/${this.getItemRequestPath(item)}`
|
||||
return `${this.opts.serverUrl}/${this.Dropbox.id}/thumbnail/${this.getItemRequestPath(item)}`
|
||||
}
|
||||
|
||||
render (state) {
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ module.exports = class GoogleDrive extends Plugin {
|
|||
</svg>
|
||||
|
||||
this[this.id] = new Provider(uppy, {
|
||||
host: this.opts.host,
|
||||
serverUrl: this.opts.serverUrl,
|
||||
provider: 'drive',
|
||||
authProvider: 'google'
|
||||
})
|
||||
|
|
@ -30,7 +30,7 @@ module.exports = class GoogleDrive extends Plugin {
|
|||
|
||||
// merge default options with the ones set by user
|
||||
this.opts = Object.assign({}, defaultOptions, opts)
|
||||
this.opts.hostPattern = opts.hostPattern || opts.host
|
||||
this.opts.serverPattern = opts.serverPattern || opts.serverUrl
|
||||
}
|
||||
|
||||
install () {
|
||||
|
|
@ -115,7 +115,7 @@ module.exports = class GoogleDrive extends Plugin {
|
|||
}
|
||||
|
||||
getItemThumbnailUrl (item) {
|
||||
return `${this.opts.host}/${this.GoogleDrive.id}/thumbnail/${this.getItemRequestPath(item)}`
|
||||
return `${this.opts.serverUrl}/${this.GoogleDrive.id}/thumbnail/${this.getItemRequestPath(item)}`
|
||||
}
|
||||
|
||||
render (state) {
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ module.exports = class Instagram extends Plugin {
|
|||
)
|
||||
|
||||
this[this.id] = new Provider(uppy, {
|
||||
host: this.opts.host,
|
||||
serverUrl: this.opts.serverUrl,
|
||||
provider: 'instagram',
|
||||
authProvider: 'instagram'
|
||||
})
|
||||
|
|
@ -33,7 +33,7 @@ module.exports = class Instagram extends Plugin {
|
|||
|
||||
// merge default options with the ones set by user
|
||||
this.opts = Object.assign({}, defaultOptions, opts)
|
||||
this.opts.hostPattern = opts.hostPattern || opts.host
|
||||
this.opts.serverPattern = opts.serverPattern || opts.serverUrl
|
||||
}
|
||||
|
||||
install () {
|
||||
|
|
|
|||
|
|
@ -190,16 +190,16 @@ module.exports = class Transloadit extends Plugin {
|
|||
// We only replace the hostname for Transloadit's uppy-servers, so that
|
||||
// people can self-host them while still using Transloadit for encoding.
|
||||
let remote = file.remote
|
||||
if (file.remote && TL_UPPY_SERVER.test(file.remote.host)) {
|
||||
if (file.remote && TL_UPPY_SERVER.test(file.remote.serverUrl)) {
|
||||
let newHost = assembly.uppyserver_url
|
||||
let path = file.remote.url.replace(file.remote.host, '')
|
||||
let path = file.remote.url.replace(file.remote.serverUrl, '')
|
||||
// remove tailing slash
|
||||
newHost = newHost.replace(/\/$/, '')
|
||||
// remove leading slash
|
||||
path = path.replace(/^\//, '')
|
||||
|
||||
remote = Object.assign({}, file.remote, {
|
||||
host: newHost,
|
||||
serverUrl: newHost,
|
||||
url: `${newHost}/${path}`
|
||||
})
|
||||
}
|
||||
|
|
|
|||
|
|
@ -271,7 +271,7 @@ module.exports = class Tus extends Plugin {
|
|||
connectToServerSocket (file) {
|
||||
return new Promise((resolve, reject) => {
|
||||
const token = file.serverToken
|
||||
const host = getSocketHost(file.remote.host)
|
||||
const host = getSocketHost(file.remote.serverUrl)
|
||||
const socket = new UppySocket({ target: `${host}/api/${token}` })
|
||||
this.uploaderSockets[file.id] = socket
|
||||
this.uploaderEvents[file.id] = createEventTracker(this.uppy)
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@ module.exports = class Url extends Plugin {
|
|||
this.translator = new Translator({locale: this.locale})
|
||||
this.i18n = this.translator.translate.bind(this.translator)
|
||||
|
||||
this.hostname = this.opts.host
|
||||
this.hostname = this.opts.serverUrl
|
||||
|
||||
if (!this.hostname) {
|
||||
throw new Error('Uppy Server hostname is required, please consult https://uppy.io/docs/server')
|
||||
|
|
@ -60,7 +60,7 @@ module.exports = class Url extends Plugin {
|
|||
|
||||
this.handlePaste = this.handlePaste.bind(this)
|
||||
|
||||
this.client = new RequestClient(uppy, {host: this.opts.host})
|
||||
this.client = new RequestClient(uppy, { serverUrl: this.opts.serverUrl })
|
||||
}
|
||||
|
||||
getFileNameFromUrl (url) {
|
||||
|
|
@ -122,7 +122,7 @@ module.exports = class Url extends Plugin {
|
|||
url: url
|
||||
},
|
||||
remote: {
|
||||
host: this.opts.host,
|
||||
serverUrl: this.opts.serverUrl,
|
||||
url: `${this.hostname}/url/get`,
|
||||
body: {
|
||||
fileId: url,
|
||||
|
|
|
|||
|
|
@ -327,7 +327,7 @@ module.exports = class XHRUpload extends Plugin {
|
|||
)
|
||||
.then((res) => {
|
||||
const token = res.token
|
||||
const host = getSocketHost(file.remote.host)
|
||||
const host = getSocketHost(file.remote.serverUrl)
|
||||
const socket = new UppySocket({ target: `${host}/api/${token}` })
|
||||
|
||||
socket.on('progress', (progressData) => emitSocketProgress(this, progressData, file))
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ module.exports = class RequestClient {
|
|||
|
||||
get hostname () {
|
||||
const { uppyServer } = this.uppy.getState()
|
||||
const host = this.opts.host
|
||||
const host = this.opts.serverUrl
|
||||
return stripSlash(uppyServer && uppyServer[host] ? uppyServer[host] : host)
|
||||
}
|
||||
|
||||
|
|
@ -30,7 +30,7 @@ module.exports = class RequestClient {
|
|||
onReceiveResponse (response) {
|
||||
const state = this.uppy.getState()
|
||||
const uppyServer = state.uppyServer || {}
|
||||
const host = this.opts.host
|
||||
const host = this.opts.serverUrl
|
||||
const headers = response.headers
|
||||
// Store the self-identified domain name for the uppy-server we just hit.
|
||||
if (headers.has('i-am') && headers.get('i-am') !== uppyServer[host]) {
|
||||
|
|
|
|||
|
|
@ -3,8 +3,8 @@ const RequestClient = require('./RequestClient')
|
|||
describe('RequestClient', () => {
|
||||
it('has a hostname without trailing slash', () => {
|
||||
const mockCore = { getState: () => ({}) }
|
||||
const a = new RequestClient(mockCore, { host: 'http://server.uppy.io' })
|
||||
const b = new RequestClient(mockCore, { host: 'http://server.uppy.io/' })
|
||||
const a = new RequestClient(mockCore, { serverUrl: 'http://server.uppy.io' })
|
||||
const b = new RequestClient(mockCore, { serverUrl: 'http://server.uppy.io/' })
|
||||
|
||||
expect(a.hostname).toBe('http://server.uppy.io')
|
||||
expect(b.hostname).toBe('http://server.uppy.io')
|
||||
|
|
|
|||
|
|
@ -182,7 +182,7 @@ module.exports = class ProviderView {
|
|||
fileId: this.plugin.getItemId(file)
|
||||
},
|
||||
remote: {
|
||||
host: this.plugin.opts.host,
|
||||
serverUrl: this.plugin.opts.serverUrl,
|
||||
url: `${this.Provider.fileUrl(this.plugin.getItemRequestPath(file))}`,
|
||||
body: {
|
||||
fileId: this.plugin.getItemId(file)
|
||||
|
|
@ -453,9 +453,9 @@ module.exports = class ProviderView {
|
|||
const authWindow = window.open(link, '_blank')
|
||||
const noProtocol = (url) => url.replace(/^(https?:|)\/\//, '')
|
||||
const handleToken = (e) => {
|
||||
const allowedOrigin = new RegExp(noProtocol(this.plugin.opts.hostPattern))
|
||||
const allowedOrigin = new RegExp(noProtocol(this.plugin.opts.serverPattern))
|
||||
if (!allowedOrigin.test(noProtocol(e.origin)) || e.source !== authWindow) {
|
||||
this.plugin.uppy.log(`rejecting event from ${e.origin} vs allowed pattern ${this.plugin.opts.hostPattern}`)
|
||||
this.plugin.uppy.log(`rejecting event from ${e.origin} vs allowed pattern ${this.plugin.opts.serverPattern}`)
|
||||
return
|
||||
}
|
||||
authWindow.close()
|
||||
|
|
|
|||
10
types/index.d.ts
vendored
10
types/index.d.ts
vendored
|
|
@ -283,7 +283,7 @@ declare namespace plugins {
|
|||
expires: number;
|
||||
serviceWorker: boolean;
|
||||
indexedDB: any;
|
||||
host: string;
|
||||
serverUrl: string;
|
||||
}
|
||||
class GoogleDrive extends core.Plugin {
|
||||
constructor(uppy: core.Uppy, opts: Partial<GoogleDriveOptions>);
|
||||
|
|
@ -296,7 +296,7 @@ declare namespace plugins {
|
|||
deleteBlobs(): Promise<any>;
|
||||
}
|
||||
interface InstagramOptions extends core.CoreConfig {
|
||||
host: string;
|
||||
serverUrl: string;
|
||||
}
|
||||
class Instagram extends core.Plugin {
|
||||
constructor(uppy: core.Uppy, opts: Partial<InstagramOptions>);
|
||||
|
|
@ -345,20 +345,20 @@ declare namespace plugins {
|
|||
constructor(uppy: core.Uppy, opts: Partial<StatusBarOptions>);
|
||||
}
|
||||
interface UrlOptions extends core.CoreConfig {
|
||||
host: string;
|
||||
serverUrl: string;
|
||||
}
|
||||
class Url extends core.Plugin {
|
||||
constructor(uppy: core.Uppy, opts: Partial<UrlOptions>);
|
||||
}
|
||||
interface DropboxOptions extends core.CoreConfig {
|
||||
host: string;
|
||||
serverUrl: string;
|
||||
}
|
||||
class Dropbox extends core.Plugin {
|
||||
constructor(uppy: core.Uppy, opts: Partial<DropboxOptions>);
|
||||
}
|
||||
interface AwsS3Options extends core.CoreConfig {
|
||||
limit: number;
|
||||
host: string;
|
||||
serverUrl: string;
|
||||
timeout: number;
|
||||
}
|
||||
class AwsS3 extends core.Plugin {
|
||||
|
|
|
|||
|
|
@ -18,8 +18,8 @@ import Uppy = require('uppy');
|
|||
(() => {
|
||||
const uppy = Uppy.Core({ autoProceed: false })
|
||||
.use(Uppy.Dashboard, { trigger: '#select-files' })
|
||||
.use(Uppy.GoogleDrive, { target: Uppy.Dashboard, host: 'https://server.uppy.io' })
|
||||
.use(Uppy.Instagram, { target: Uppy.Dashboard, host: 'https://server.uppy.io' })
|
||||
.use(Uppy.GoogleDrive, { target: Uppy.Dashboard, serverUrl: 'https://server.uppy.io' })
|
||||
.use(Uppy.Instagram, { target: Uppy.Dashboard, serverUrl: 'https://server.uppy.io' })
|
||||
.use(Uppy.Webcam, { target: Uppy.Dashboard })
|
||||
.use(Uppy.Tus, { endpoint: 'https://master.tus.io/files/' })
|
||||
.run()
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ The `AwsS3Multipart` plugin can be used to upload files directly to an S3 bucket
|
|||
const AwsS3Multipart = require('uppy/lib/plugins/AwsS3/Multipart')
|
||||
uppy.use(AwsS3Multipart, {
|
||||
limit: 4,
|
||||
host: 'https://uppy-server.myapp.net/'
|
||||
serverUrl: 'https://uppy-server.myapp.net/'
|
||||
})
|
||||
```
|
||||
|
||||
|
|
@ -21,7 +21,7 @@ uppy.use(AwsS3Multipart, {
|
|||
|
||||
The maximum amount of chunks to upload simultaneously. `0` means unlimited.
|
||||
|
||||
### host: null
|
||||
### serverUrl: null
|
||||
|
||||
The Uppy Server URL to use to proxy calls to the S3 Multipart API.
|
||||
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ const ms = require('ms')
|
|||
uppy.use(AwsS3, {
|
||||
limit: 2,
|
||||
timeout: ms('1 minute'),
|
||||
host: 'https://uppy-server.myapp.com/'
|
||||
serverUrl: 'https://uppy-server.myapp.com/'
|
||||
})
|
||||
```
|
||||
|
||||
|
|
@ -29,13 +29,13 @@ There is also a separate plugin for S3 Multipart uploads. Multipart in this sens
|
|||
|
||||
A unique identifier for this plugin. Defaults to `'AwsS3'`.
|
||||
|
||||
### `host`
|
||||
### `serverUrl`
|
||||
|
||||
When using [uppy-server][uppy-server docs] to sign S3 uploads, set this option to the root URL of the uppy-server.
|
||||
|
||||
```js
|
||||
uppy.use(AwsS3, {
|
||||
host: 'https://uppy-server.my-app.com/'
|
||||
serverUrl: 'https://uppy-server.my-app.com/'
|
||||
})
|
||||
```
|
||||
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ uppy.use(Dropbox, {
|
|||
```js
|
||||
uppy.use(Dropbox, {
|
||||
target: Dashboard,
|
||||
host: 'https://server.uppy.io/',
|
||||
serverUrl: 'https://server.uppy.io/',
|
||||
})
|
||||
```
|
||||
|
||||
|
|
@ -36,7 +36,7 @@ A unique identifier for this plugin. Defaults to `'Dropbox'`.
|
|||
|
||||
DOM element, CSS selector, or plugin to mount the Dropbox provider into. This should normally be the Dashboard.
|
||||
|
||||
### `host: null`
|
||||
### `serverUrl: null`
|
||||
|
||||
URL to an Uppy Server instance.
|
||||
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ uppy.use(GoogleDrive, {
|
|||
```js
|
||||
uppy.use(GoogleDrive, {
|
||||
target: Dashboard,
|
||||
host: 'https://server.uppy.io/',
|
||||
serverUrl: 'https://server.uppy.io/',
|
||||
})
|
||||
```
|
||||
|
||||
|
|
@ -36,7 +36,7 @@ A unique identifier for this plugin. Defaults to `'GoogleDrive'`.
|
|||
|
||||
DOM element, CSS selector, or plugin to mount the GoogleDrive provider into. This should normally be the Dashboard.
|
||||
|
||||
### `host: null`
|
||||
### `serverUrl: null`
|
||||
|
||||
URL to an Uppy Server instance.
|
||||
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ uppy.use(Instagram, {
|
|||
```js
|
||||
uppy.use(Instagram, {
|
||||
target: Dashboard,
|
||||
host: 'https://server.uppy.io/',
|
||||
serverUrl: 'https://server.uppy.io/',
|
||||
})
|
||||
```
|
||||
|
||||
|
|
@ -36,7 +36,7 @@ A unique identifier for this plugin. Defaults to `'Instagram'`.
|
|||
|
||||
DOM element, CSS selector, or plugin to mount the Instagram provider into. This should normally be the Dashboard.
|
||||
|
||||
### `host: null`
|
||||
### `serverUrl: null`
|
||||
|
||||
URL to an Uppy Server instance.
|
||||
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ The Provider plugins help you connect to your accounts with remote file provider
|
|||
|
||||
As of now, the supported providers are [**Dropbox**](/docs/dropbox), [**GoogleDrive**](/docs/google-drive), [**Instagram**](/docs/instagram), and [**Url**](/docs/url).
|
||||
|
||||
Usage of the Provider plugins is not that different from any other *acquirer* plugin, except that it takes an extra option `host`, which specifies the url to your running `uppy-server`. This allows Uppy to know what server to connect to when server related operations are required by the provider plugin. Here's a quick example.
|
||||
Usage of the Provider plugins is not that different from any other *acquirer* plugin, except that it takes an extra option `serverUrl`, which specifies the url to your running `uppy-server`. This allows Uppy to know what server to connect to when server related operations are required by the provider plugin. Here's a quick example.
|
||||
|
||||
```js
|
||||
const Uppy = require('uppy/lib/core')
|
||||
|
|
@ -21,17 +21,17 @@ uppy.use(Dashboard, {
|
|||
|
||||
// for Google Drive
|
||||
const GoogleDrive = require('uppy/lib/plugins/GoogleDrive')
|
||||
uppy.use(GoogleDrive, {target: Dashboard, host: 'http://localhost:3020'})
|
||||
uppy.use(GoogleDrive, {target: Dashboard, serverUrl: 'http://localhost:3020'})
|
||||
|
||||
// for Dropbox
|
||||
const Dropbox = require('uppy/lib/plugins/Dropbox')
|
||||
uppy.use(Dropbox, {target: Dashboard, host: 'http://localhost:3020'})
|
||||
uppy.use(Dropbox, {target: Dashboard, serverUrl: 'http://localhost:3020'})
|
||||
|
||||
// for Instagram
|
||||
const Instagram = require('uppy/lib/plugins/Instagram')
|
||||
uppy.use(Instagram, {target: Dashboard, host: 'http://localhost:3020'})
|
||||
uppy.use(Instagram, {target: Dashboard, serverUrl: 'http://localhost:3020'})
|
||||
|
||||
// for Url
|
||||
const Url = require('uppy/lib/plugins/Url')
|
||||
uppy.use(Url, {target: Dashboard, host: 'http://localhost:3020'})
|
||||
uppy.use(Url, {target: Dashboard, serverUrl: 'http://localhost:3020'})
|
||||
```
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ const Dropbox = require('uppy/lib/plugins/Dropbox')
|
|||
const Transloadit = require('uppy/lib/plugins/Transloadit')
|
||||
|
||||
uppy.use(Dropbox, {
|
||||
host: Transloadit.UPPY_SERVER
|
||||
serverUrl: Transloadit.UPPY_SERVER
|
||||
})
|
||||
```
|
||||
|
||||
|
|
@ -45,7 +45,7 @@ The value of this constant is `https://api2.transloadit.com/uppy-server`. If you
|
|||
|
||||
```js
|
||||
uppy.use(Dropbox, {
|
||||
host: 'https://api2-us-east-1.transloadit.com/uppy-server'
|
||||
serverUrl: 'https://api2-us-east-1.transloadit.com/uppy-server'
|
||||
})
|
||||
```
|
||||
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ uppy.use(Url, {
|
|||
```js
|
||||
uppy.use(Url, {
|
||||
target: Dashboard,
|
||||
host: 'https://server.uppy.io/',
|
||||
serverUrl: 'https://server.uppy.io/',
|
||||
locale: {}
|
||||
})
|
||||
```
|
||||
|
|
@ -37,7 +37,7 @@ A unique identifier for this plugin. Defaults to `'Url'`.
|
|||
|
||||
DOM element, CSS selector, or plugin to mount the Url provider into. This should normally be the Dashboard.
|
||||
|
||||
### `host: null`
|
||||
### `serverUrl: null`
|
||||
|
||||
URL to an Uppy Server instance.
|
||||
|
||||
|
|
|
|||
|
|
@ -49,19 +49,19 @@ function uppyInit () {
|
|||
})
|
||||
|
||||
if (opts.GoogleDrive) {
|
||||
uppy.use(GoogleDrive, { target: Dashboard, host: UPPY_SERVER })
|
||||
uppy.use(GoogleDrive, { target: Dashboard, serverUrl: UPPY_SERVER })
|
||||
}
|
||||
|
||||
if (opts.Dropbox) {
|
||||
uppy.use(Dropbox, { target: Dashboard, host: UPPY_SERVER })
|
||||
uppy.use(Dropbox, { target: Dashboard, serverUrl: UPPY_SERVER })
|
||||
}
|
||||
|
||||
if (opts.Instagram) {
|
||||
uppy.use(Instagram, { target: Dashboard, host: UPPY_SERVER })
|
||||
uppy.use(Instagram, { target: Dashboard, serverUrl: UPPY_SERVER })
|
||||
}
|
||||
|
||||
if (opts.Url) {
|
||||
uppy.use(Url, { target: Dashboard, host: UPPY_SERVER })
|
||||
uppy.use(Url, { target: Dashboard, serverUrl: UPPY_SERVER })
|
||||
}
|
||||
|
||||
if (opts.Webcam) {
|
||||
|
|
|
|||
|
|
@ -50,9 +50,9 @@ const uppy = Uppy({
|
|||
{ id: 'caption', name: 'Caption', placeholder: 'describe what the image is about' }
|
||||
]
|
||||
})
|
||||
.use(GoogleDrive, { target: Dashboard, host: 'https://server.uppy.io' })
|
||||
.use(Dropbox, { target: Dashboard, host: 'https://server.uppy.io' })
|
||||
.use(Instagram, { target: Dashboard, host: 'https://server.uppy.io' })
|
||||
.use(GoogleDrive, { target: Dashboard, serverUrl: 'https://server.uppy.io' })
|
||||
.use(Dropbox, { target: Dashboard, serverUrl: 'https://server.uppy.io' })
|
||||
.use(Instagram, { target: Dashboard, serverUrl: 'https://server.uppy.io' })
|
||||
.use(Webcam, { target: Dashboard })
|
||||
.use(Tus, { endpoint: 'https://master.tus.io/files/' })
|
||||
|
||||
|
|
|
|||
|
|
@ -57,7 +57,7 @@ function initUppy () {
|
|||
target: '#uppy-dashboard-container',
|
||||
note: 'Images only, 1–2 files, up to 1 MB'
|
||||
})
|
||||
.use(Instagram, { target: Dashboard, host: 'https://api2.transloadit.com/uppy-server' })
|
||||
.use(Instagram, { target: Dashboard, serverUrl: 'https://api2.transloadit.com/uppy-server' })
|
||||
.use(Webcam, { target: Dashboard })
|
||||
|
||||
uppy
|
||||
|
|
|
|||
|
|
@ -125,7 +125,7 @@ uppy
|
|||
},
|
||||
waitForEncoding: true
|
||||
})
|
||||
.use(Instagram, { target: Dashboard, host: 'https://api2.transloadit.com/uppy-server' })
|
||||
.use(Instagram, { target: Dashboard, serverUrl: 'https://api2.transloadit.com/uppy-server' })
|
||||
.use(Dashboard, {
|
||||
inline: true,
|
||||
maxHeight: 400,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue