-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.html
46 lines (40 loc) · 1.38 KB
/
index.html
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
<html>
<head>
<script
src="//static.filestackapi.com/filestack-js/3.x.x/filestack.min.js"
crossorigin="anonymous"
></script>
<script src="/socket.io/socket.io.js"></script>
</head>
<body>
<button id="upload">Upload file</button>
<div id="result" style="width:800;height:600;padding:10px;border: 1px solid red; background-color: #aaa;">
</div>
<script>
document.addEventListener('DOMContentLoaded', () => {
const client = filestack.init('YOUR_API_KEY');
const options = {
storeTo: {
workflows: ['WORKFLOW_ID'],
},
onUploadDone: () => {
document.querySelector('#result').innerHTML = '<div style="width:100%;height:100%;display:flex;align-items:center;justify-content:center;font-size:20px;color:red"> Waiting for results ...</div>'
}
};
picker = client.picker(options);
document.querySelector('#upload').addEventListener('click', () => {
picker.open();
});
const socket = io();
socket.on('result', (res) => {
const img = document.createElement('img');
console.log(res.data.url);
img.src = res.data.url;
const resDiv = document.querySelector('#result');
resDiv.innerHTML = '';
resDiv.appendChild(img);
})
});
</script>
</body>
</html>