quentin.dufour.io/demo/edit/index.html

51 lines
1.4 KiB
HTML
Raw Permalink Normal View History

2022-12-04 16:11:31 +00:00
<!doctype html>
<html>
<head>
<title>Small web IDE</title>
<meta charset="utf-8"/>
</head>
<body>
<h1>Small web IDE</h1>
<script src="https://unpkg.com/aws4-tiny@1.0.0/dist/aws4.js"></script>
<script>
let aki = localStorage.getItem('accessKeyId');
if (aki === null) {
aki = window.prompt("What is your Garage Access Key ID?");
localStorage.setItem('accessKeyId', aki);
}
let sak = localStorage.getItem('secretAccessKey');
if (sak === null) {
sak = window.prompt("What is you Garage Secret Access Key?");
localStorage.setItem("secretAccessKey", sak);
}
const credentials = {
accessKeyId: aki,
secretAccessKey: sak,
};
const opts = {
region: 'garage',
service: 's3',
host: 'garage.deuxfleurs.fr',
path: '/quentin.dufour.io/?list-type=2',
headers: {
'x-amz-content-sha256': 'UNSIGNED-PAYLOAD',
},
};
const req = aws4.sign(opts, credentials);
console.log(req)
async function ListObjectsV2() {
const res = await fetch('https://garage.deuxfleurs.fr/quentin.dufour.io/?list-type=2', req);
const body = await res.text()
console.log("body raw", body)
const objList = new window.DOMParser().parseFromString(body, "text/xml")
console.log("parsed body", objList)
}
ListObjectsV2()
</script>
</body>
</html>