Last active
January 15, 2021 21:45
-
-
Save jeremymeng/b01953832e1841554e91214a12fc88b5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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