Skip to content

Instantly share code, notes, and snippets.

@jeremymeng
Last active January 15, 2021 21:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jeremymeng/b01953832e1841554e91214a12fc88b5 to your computer and use it in GitHub Desktop.
Save jeremymeng/b01953832e1841554e91214a12fc88b5 to your computer and use it in GitHub Desktop.
const client = new BlobServiceClient(url);
async function testUploadProgress() {
const containerClient = client.getContainerClient("jeremy-test");
const blockBlobClient = containerClient.getBlockBlobClient(
"test-upload-progress"
);
const selectedFile = document.getElementById("input").files[0];
const status = document.getElementById("status");
await blockBlobClient.stageBlock(btoa("1"), selectedFile, selectedFile.size, {
onProgress: (e) => {
console.log("bytes sent: " + e.loadedBytes);
status.innerText = "progress: bytes sent: " + e.loadedBytes;
},
});
}
client.getProperties().then((properties) => {
console.log(properties);
const button = document.getElementById("uploadButton");
button.addEventListener("click", () => {
testUploadProgress().catch((e) => {
console.log("upload error", e);
});
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment