I'm trying to simulate a move action (as I haven't seen any move method as such) by copying and deleting blobs between two directories within the same container.
For example, inside container A
, moving .csv
blobs from Folder_1
into Folder_2
and then deleting /year/month/day
folder structure from Folder 1
container A
|_ Folder_1
|_ _ _/year/month/day/a.csv
|
|_ Folder_2
What I currently have looks like the following piece of code:
String blobUrl = "Folder_1 a.csv blob url"
String blobName = "a.csv"
BlobContainerClient outputContainerClient = outputBlobServiceClient.getBlobContainerClient("Container A");
// Folder_1 client
BlobClient tempBlobClient=outputContainerClient.getBlobClient("Folder_1/year/month/day/" + blobName);
// Folder_2 client
BlobClient destBlobClient=outputContainerClient.getBlobClient("Folder_2/year/month/day/" + blobName);
// Copy from Folder_1 to Folder_2
destBlobClient.beginCopy(blobUrl,null);
// Delete Folder_1
tempBlobClient.delete();
The problem is that the tempBlobClient.delete()
deletes the original a.csv
but not the directory structure of Folder_1/year/month/day/
. It leaves that path without a file but the directories remain undeleted.
Any ideas on how to deal with this problem?
Thanks a lot