Quick start with HTML · JS
Make your first files upload in your web browser.
Once you have created your Smash Account for free and generated your first API Key, you can start to create your first transfer from the example code below:
Code example:
Replace "Put an API key here" with your own.
<!DOCTYPE html>
<html lang="en-US">
<head>
<meta charset="UTF-8" />
<script src="https://unpkg.com/@smash-sdk/uploader/dist/SmashUploader.browser.js"></script>
</head>
<body>
<form name="uploadForm">
<input id="uploadInput" type="file" multiple>
<input type="button" onclick="upload();" value="Send file(s)">
</form>
<script>
function upload() {
const fileInput = document.getElementById("uploadInput");
const su = new SmashUploader({ region: "eu-west-3", token: "Put your api key here" })
su.upload({ files: [...fileInput.files] })
.then(transfer => { console.log("Transfer", transfer); })
.catch(error => { console.log("Error", error); });
su.on('progress', (event) => { console.log(event.data.progress.percent); });
}
</script>
</body>
</html>
Docs / Quick start / HTML · JS