-
Notifications
You must be signed in to change notification settings - Fork 2k
/
Dashboard.js
63 lines (58 loc) · 2.33 KB
/
Dashboard.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
const Uppy = require('@uppy/core/src')
const Dashboard = require('@uppy/dashboard/src')
const Instagram = require('@uppy/instagram/src')
const Facebook = require('@uppy/facebook/src')
const OneDrive = require('@uppy/onedrive/src')
const Dropbox = require('@uppy/dropbox/src')
const GoogleDrive = require('@uppy/google-drive/src')
const Url = require('@uppy/url/src')
const Webcam = require('@uppy/webcam/src')
const Tus = require('@uppy/tus/src')
// const XHRUpload = require('@uppy/xhr-upload/src')
const Form = require('@uppy/form/src')
const TUS_ENDPOINT = 'https://master.tus.io/files/'
// const XHR_ENDPOINT = 'https://upload-endpoint.uppy.io/upload'
module.exports = () => {
const uppyDashboard = Uppy({
logger: Uppy.debugLogger,
meta: {
username: 'John',
license: 'Creative Commons'
}
})
.use(Dashboard, {
trigger: '#pick-files',
// inline: true,
target: '.foo',
metaFields: [
{ id: 'license', name: 'License', placeholder: 'specify license' },
{ id: 'caption', name: 'Caption', placeholder: 'add caption' }
],
showProgressDetails: true,
proudlyDisplayPoweredByUppy: true,
note: '2 files, images and video only'
})
.use(GoogleDrive, { target: Dashboard, companionUrl: 'http://localhost:3020' })
.use(Instagram, { target: Dashboard, companionUrl: 'http://localhost:3020' })
.use(Dropbox, { target: Dashboard, companionUrl: 'http://localhost:3020' })
.use(Facebook, { target: Dashboard, companionUrl: 'http://localhost:3020' })
.use(OneDrive, { target: Dashboard, companionUrl: 'http://localhost:3020' })
.use(Url, { target: Dashboard, companionUrl: 'http://localhost:3020' })
.use(Webcam, { target: Dashboard })
.use(Tus, { endpoint: TUS_ENDPOINT })
// .use(XHRUpload, { endpoint: XHR_ENDPOINT, bundle: true })
.use(Form, { target: '#upload-form' })
// .use(GoldenRetriever, {serviceWorker: true})
window.uppy = uppyDashboard
uppyDashboard.on('complete', (result) => {
if (result.failed.length === 0) {
console.log('Upload successful 😀')
} else {
console.warn('Upload failed 😞')
}
console.log('successful files:', result.successful)
console.log('failed files:', result.failed)
})
const modalTrigger = document.querySelector('#pick-files')
if (modalTrigger) modalTrigger.click()
}