Reputation: 11
How to create sub directory in Windows Azure blob container? I know we can use blob name like "content/2015/images/mypicture.jpg".
But we need to change parent directory name. Sub directory may contain many files. Change every blob name in sub directory will take time. How to do this? I have read below links. But they don't mention how to handle rename parent directory. Thanks
Windows Azure: How to create sub directory in a blob container
How to create a sub container in azure storage location
Upvotes: 0
Views: 6032
Reputation: 136366
But we need to change parent directory name. Sub directory may contain many files. Change every blob name in sub directory will take time. How to do this?
So, there are two things in blob storage:
Here's how you can rename a folder in blob storage:
ListBlobs
method and pass in the name of the folder as prefix
parameter. See my answer here: How to load list of Azure blob files recursively?.old folder name
with new folder name
.You can also combine step 2 and 3 and do copy + delete operation on each blob. So you iterate over your list of blobs, first copy it with new name, delete it and then move on to the next blobs.
The bottom line is that you would need to do Copy+Delete
on each blob in the folder to rename that folder.
Upvotes: 2