I currently have my files stored in Azure and I am looking for a way to either download or view them on the client side. This is how I envision the process:
Azure -> Api -> Client UI (Aurelia)
While I have come across several C# examples, I am unsure of how to bring the file to the UI side. Can anyone provide some assistance?
Thank you!
Edit:
Here is the code for the API:
public string getUtf8Text()
{
CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient();
var containerName = "myContainer";
var blobName = "myBlobName.pdf";
CloudBlobContainer container = blobClient.GetContainerReference(containerName);
CloudBlockBlob blockBlob = container.GetBlockBlobReference(blobName);
string text;
using (var memoryStream = new MemoryStream())
{
await blockBlob.DownloadToStreamAsync(memoryStream);
text = System.Text.Encoding.UTF8.GetString(memoryStream.ToArray());
return text;
}
}
When attempting to download a file from the utf8 byte string, the client side code is as follows:
var byteCharacters =result.byteArray;
var byteNumbers = new Array(result.byteArray.length);
for (var i = 0; i < byteCharacters.length; i++) {
byteNumbers[i] = byteCharacters.charCodeAt(i);
}
var byteArray = new Uint8Array(byteNumbers);
var octetStreamMime = "application/octet-stream";
var contentType = octetStreamMime;
var blob = new Blob([byteArray] {type: contentType});
FileSaver.saveAs(blob, result.blobName);
While this method works occasionally for PDFs, other times it displays blank pages. Moreover, when trying to download an MP4 file, it seems to hang indefinitely. Any insight into what might be causing these issues?