-
Notifications
You must be signed in to change notification settings - Fork 17
Expand file tree
/
Copy pathbrowser-upload-test.html
More file actions
32 lines (32 loc) · 1.05 KB
/
browser-upload-test.html
File metadata and controls
32 lines (32 loc) · 1.05 KB
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>APS Binary Transfer Demo</title>
</head>
<body>
<input type="file" name="input" id="input">
<button onclick="upload()">Upload</button>
<script src="dist/browser/aps-sdk-node.js"></script>
<script>
async function upload() {
const input = document.getElementById('input');
if (input.files.length !== 1) {
return;
}
/** @type {File} */
const file = input.files[0];
const buff = await file.arrayBuffer();
const client = new APS.DataManagementClient({ token: '...' });
try {
const obj = await client.uploadObject('...', file.name, buff, { contentType: 'image/png' });
console.log(obj);
} catch (err) {
console.error(err);
}
}
</script>
</body>
</html>