I'm currently working on developing some set of codes to display all blobs inside specified Azure Container using web front-end. I'm expecting the final output to be something like this:
I started by creating a dummy storage account and populates it with some dummy files for me to play around with.
https://alicebob.blob.core.windows.net/documents ├── docx │ ├── 201801_Discussion.docx │ ├── 201802_Discussion.docx ├── xlsx │ ├── 201801_Summary.xlsx │ ├── 201802_Summary.xlsx │ ├── 201803_Summary.xlsx ├── 201801_Review.pdf ├── 201802_Review.pdf ├── 201803_Review.pdf
.js files) in Azure Static website
$web container and set
Index document name and
Error document path in the Static website configuration.
https://alicebob.z23.web.core.windows.net/ ├── azure-storage.blob.min.js ├── azure-storage.common.min.js ├── index.html
The problem is that the function to do the listing is only either
listBlobDirectoriesSegmentedWithPrefix. So, in my case, I assume it wouldn't work straightforwardly to list all the blobs and directories in a well-structured / tree format.
My current approach is that I trick the code to keep using
listBlobDirectoriesSegmentedWithPrefix until there is no more directory to list inside, then continue to list using
So far I'm quite satisfied that my code can list all the Blobs at the leaf-level and also list all the directories if it isn't on the leaf-level. You can take a look at the blob listing here and feel free to go for 'View Source' to see the codes I built so far.
The only problem that I face is that this set of code fails to list the Blobs if it wasn't on the leaf-level. For example, it fails to list these blobs on
alicebob storage account:
├── 201801_Review.pdf ├── 201802_Review.pdf ├── 201803_Review.pdf
This is an expected issue as I'm not running
listBlobsSegmentedWithPrefix if it isn't on the leaf-level. The reason is that it will produces the output with something like this which isn't what I want:
├── docx/201801_Discussion.docx ├── docx/201802_Discussion.docx ├── xlsx/201801_Summary.xlsx ├── xlsx/201802_Summary.xlsx ├── xlsx/201803_Summary.xlsx ├── 201801_Review.pdf ├── 201802_Review.pdf ├── 201803_Review.pdf
Any suggestion on how to overcome this issue? The real implementation would involves a huge amount of data so I think a simple if-then-else wouldn't be efficient on this case.
sorry for the long description but I just want to describe my problem as clear as possible :)