[Azure Blob Storage] How to list files inside a directory?
azure-blob-storage
Web icon
Forge component by Barduino
Application Type
Traditional Web

I am trying to see if I can use this component in a project, but I am hitting a wall.

It seems I cannot list blobs inside a directory.

Example:

When I call the ListBlobs action, I see: my-directory, document.docx, and book.xls.

But now, I want to list the contents of my-directory and there is no action available to do that, is there?

The ListBlobs lists everything under my-container. If I want to go deeper in the nested folders I can't.


my-container/

├─ my-directory/

│  ├─ image-inside-directory.png

├─ document.docx

├─ book.xls


Thanks,

João Heleno

Solution

Hi João,

First of all. There are no directories or folder support in Azure Storage Accounts. What you think is an folder is nothing more then the name of a blob containing slashes. So an empty ListBlobs action should return all 3 files (and probably does) namely my-directory/image-inside-directory.png, document.docx and book.xls. 

You can use the Prefix parameter to start filtering blobs. So an value of "document" will return document.docx and a value of "my-directory" will return my-directory/image-inside-directory.png. 

Please note that in Azure Data Lake Gen 2 there is folder support but this component should not fully support that though.

Hope this helps,

Vincent

Hi Vincent,

Thank you for your reply.

I realize that now. In the past, I worked with Azure File Share and I still had the "folder" concept in my mind.

Time to adapt.

Cheers,

João

@Vincent Koning 

When I use slashes in my blobs, why don't I see the complete blob filename when calling the List action?

I uploaded a blob named "outsystems/file.txt" and when I list my container I am missing "file.txt"...

Without the full name I cannot use this component :) ... and I want to use it!!



Hi João,

That is strange and should not happen. Any change you can share your OML so I can take a look at it? Make sure to remove any connection strings before sharing!

Greetings,

Vincent

Thank you for replying, Vincent.

I cannot upload the OML but, there is not much to see.

I pass the connection string, the container name, and the filename.



Hello, you can try below procedure..

in ListBlob action Assign properties like below

ConnectionString ->your connection string

ContainerName ->Your Container Name [ Ex: testContainer ]

Prefix -> Your folder Name fallowed by slash (/) [ Ex: testfolder/ ]


after given above properties you will get all the files inside your folder like below

testfolder/filename1.jpg

testfolder/filename2.jpg

testfolder/filename3.png etc..


Now loop your list blobs and in each loop use string_split function with (/) delimeter

then use DownloadBlob action and set properties like below


ConnectionString -> your connection string

ContainerName ->   your Container Name / your folder name [Ex : testContainer/testfolder ]

Name ->    String_Split.List[1].Text.Value


you will get the blob file now add this to list using "ListAppend"






@Sandeep Kumar Kolli 

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.