I am currently working on uploading the screenshot of React UI to the Azure blob storage.
But I have some issues when I upload the screenshot image.
Here is my part of codebase.
./src/captureError.js
export const getCapturedImageBlob = async (container) => {
const screenshot = await html2canvas(container);
return screenshot;
}
export const uploadImageToBlobStorage = (screenshot, connection_string, container_name, blob_name) => {
screenshot.toBlob(blob => {
console.log(blob);
const blobServiceClient = new BlobServiceClient(connection_string);
const containerClient = blobServiceClient.getContainerClient(container_name);
const blobClient = containerClient.getBlockBlobClient(blob_name);
blobClient.uploadData(blob);
})
}
./src/App.js
const screenshot = await getCapturedImageBlob(document.querySelector("#root"));
uploadImageToBlobStorage(screenshot, 'https://{Account Name}.blob.core.windows.net', {Container Name}, {Blob name});
Once I tried to upload the screenshot, I got this error.
PUT https://{Account Name}.blob.core.windows.net/{Container Name}/{Blob Name}?{Account Key} 401 (Server failed to authenticate the request. Please refer to the information in the www-authenticate header.)