/
main.js
53 lines (49 loc) · 1.35 KB
/
main.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
const Uppy = require('@uppy/core')
const Dashboard = require('@uppy/dashboard')
const Transloadit = require('@uppy/transloadit')
function initUppyTransloadit (transloaditKey) {
const uppyTransloadit = new Uppy({
id: 'uppyTransloadit',
debug: true,
autoProceed: true,
})
uppyTransloadit
.use(Dashboard, {
target: '#uppy-transloadit',
inline: true,
})
.use(Transloadit, {
service: 'https://api2-ap-southeast-1.transloadit.com',
params: {
steps: {
crop_thumbed: {
use: [':original'],
robot: '/image/resize',
height: 100,
resize_strategy: 'crop',
width: 100,
},
},
},
getAssemblyOptions () {
return {
params: {
auth: { key: transloaditKey },
template_id: 'uppyTransloadit',
},
fields: {
message: 'test',
},
}
},
waitForEncoding: true,
})
uppyTransloadit.on('transloadit:result', (_, __, assembly) => {
// use transloadit encoding result here.
const result = document.createElement('div')
result.setAttribute('id', 'uppy-result')
result.textContent = assembly.fields.message === 'test' ? 'ok' : 'fail'
document.body.appendChild(result)
})
}
window.initUppyTransloadit = initUppyTransloadit