mirror of
https://github.com/transloadit/uppy.git
synced 2026-07-18 17:16:00 +00:00
Fixes: https://github.com/transloadit/uppy/issues/3473 Co-authored-by: Antoine du Hamel <duhamelantoine1995@gmail.com> Co-authored-by: Mikael Finstad <finstaden@gmail.com>
39 lines
1.2 KiB
JavaScript
39 lines
1.2 KiB
JavaScript
// The @uppy/ dependencies are resolved from source
|
|
/* eslint-disable import/no-extraneous-dependencies */
|
|
import Uppy from '@uppy/core'
|
|
import Tus from '@uppy/tus'
|
|
import DragDrop from '@uppy/drag-drop'
|
|
import ProgressBar from '@uppy/progress-bar'
|
|
/* eslint-enable import/no-extraneous-dependencies */
|
|
|
|
// DEV CONFIG: create a .env file in the project root directory to customize those values.
|
|
const {
|
|
VITE_TUS_ENDPOINT : TUS_ENDPOINT,
|
|
} = import.meta.env
|
|
|
|
import.meta.env.VITE_TRANSLOADIT_KEY = '***' // to avoid leaking secrets in screenshots.
|
|
console.log(import.meta.env)
|
|
|
|
export default () => {
|
|
const uppyDragDrop = new Uppy({
|
|
debug: true,
|
|
autoProceed: true,
|
|
})
|
|
.use(DragDrop, {
|
|
target: '#uppyDragDrop',
|
|
})
|
|
.use(ProgressBar, { target: '#uppyDragDrop-progress', hideAfterFinish: false })
|
|
.use(Tus, { endpoint: TUS_ENDPOINT })
|
|
|
|
window.uppy = uppyDragDrop
|
|
|
|
uppyDragDrop.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)
|
|
})
|
|
}
|