/
index.html
55 lines (46 loc) · 1.59 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
47
48
49
50
51
52
53
54
55
<html>
<body>
<style>
body {
background-color: #000;
}
img:hover {
cursor: pointer;
outline: 1px solid #fff;
z-index: 100;
position: relative;
}
</style>
<main>
<div id="eleImages"></div>
</main>
<script type="module">
import { CCAPI } from "./lib.js";
const camera = new CCAPI(location.host);
const storageList = await camera.storage();
const storage = storageList[0];
if (!storage) {
throw new Error("No storage found");
}
const files = await camera.files(storage);
console.log(files);
for (const filePath of files) {
const img = document.createElement("img");
const blob = await camera.thumbnail(filePath);
img.src = URL.createObjectURL(blob);
img.onclick = async () => {
const blob = await camera.original(filePath);
const fileName = filePath.split("/").pop();
const file = new File([blob], fileName, {
type: "image/x-canon-cr3",
});
const a = document.createElement("a");
a.href = URL.createObjectURL(file);
a.download = file.name;
a.click();
};
eleImages.appendChild(img);
}
</script>
</body>
</html>