diff --git a/public/index.html b/public/index.html
index f731b96..97ffbe5 100644
--- a/public/index.html
+++ b/public/index.html
@@ -64,6 +64,19 @@
});
});
+ app.ports.uploadMedia.subscribe(data => {
+ const files = Array.from(document.getElementById(data.id).files);
+ const formData = new FormData();
+ formData.append("file", files[0]);
+ fetch(data.url, {
+ method: "POST",
+ headers: { Authorization: "Bearer " + data.token },
+ body: formData,
+ })
+ .catch(err => app.ports.uploadError.send(err.message))
+ .then(response => response.text())
+ .then(app.ports.uploadSuccess.send);
+ });