|
@@ -3,6 +3,7 @@ require('whatwg-fetch')
|
|
|
const Uppy = require('@uppy/core')
|
|
|
const Dashboard = require('@uppy/dashboard')
|
|
|
const Tus = require('@uppy/tus')
|
|
|
+const canvasToBlob = require('@uppy/utils/lib/canvasToBlob')
|
|
|
|
|
|
const isOnTravis = !!(process.env.TRAVIS && process.env.CI)
|
|
|
const endpoint = isOnTravis ? 'http://companion.test:1081' : 'http://localhost:1081'
|
|
@@ -20,7 +21,7 @@ window.setup = function (options) {
|
|
|
limit: options.limit
|
|
|
})
|
|
|
uppy.on('file-added', (file) => {
|
|
|
- randomColorImage(function (blob) {
|
|
|
+ randomColorImage().then(function (blob) {
|
|
|
uppy.setFileState(file.id, { preview: URL.createObjectURL(blob) })
|
|
|
})
|
|
|
})
|
|
@@ -28,12 +29,12 @@ window.setup = function (options) {
|
|
|
return uppy
|
|
|
}
|
|
|
|
|
|
-function randomColorImage (callback) {
|
|
|
+function randomColorImage () {
|
|
|
const canvas = document.createElement('canvas')
|
|
|
canvas.width = 140
|
|
|
canvas.height = 140
|
|
|
const context = canvas.getContext('2d')
|
|
|
context.fillStyle = '#xxxxxx'.replace(/x/g, () => '0123456789ABCDEF'[Math.floor(Math.random() * 16)])
|
|
|
context.fillRect(0, 0, 140, 140)
|
|
|
- canvas.toBlob(callback)
|
|
|
+ return canvasToBlob(canvas)
|
|
|
}
|