Reputation: 2453
I want to create folder using azure blob rest api and also wants to check whether a folder exists or not.
Hierarchy:
arjun/images/
arjun/Videos/001.avi
arjun/Vidos/002.avi
img001.jpg
I tried to send a PUT request in order to create a folder with path for example
"arjun/images/"
:
- This creates a folder but its not empty.
- It is creating an empty file with no name inside the folder.
Now, even if this is correct another problem is when I want to check whether a folder exists:
200 Ok message
with Blob element empty
. So, can't tell whether a folder doesn't exists or is empty.
i.e. a blob list request with prefix
"arjun/xyz/"
and"arjun/images/
both will be successful but will have response body empty as both doesn't contain any content. But, in reality first folder xyz doesn't exist and second folder exists but empty.
Upvotes: 1
Views: 2043
Reputation: 24539
As David Makogon and juvchan mentioned that there is no folder hierarchy for Azure storage blob. If there is no blob in the "folder", it is the same meaning that the "folder" is not existed. If there are blobs in the "folder" then we can get the list blob counts from the List blobs API response body. So we have no need to worry about whether a folder not exist or empty, they both mean that it is not existed.
Upvotes: 2
Reputation: 6245
The Blob service is based on a flat storage scheme, not a hierarchical scheme.
Source: Blob Names
This clearly indicates that there is actually no folder hierarchy for Azure Storage Blob and the "folder" are just virtual directory for creating virtual hierarchy.
Furthermore, if you are trying to use the Microsoft Storage Explorer to create a virtual directory, it also highlights to you that the virtual directory is not exist until you put a blob into it, which makes prefect sense since the virtual directory in fact is just part of the name of the blob.
In conclusion, the virtual directory does not exist if you "create" it without uploading any blob into it.
Upvotes: 2