QuentinCG / QAzureStorageRestApi

[Done] Standalone Azure Storage REST API client for Qt5+ & Qt6+ (Tested with Qt 5.12.12 & Qt 6.2.3)
MIT License
2 stars 4 forks source link

Make or Remove directory in Blob Container #9

Closed fverneau closed 11 months ago

fverneau commented 11 months ago

Would it be possible to have a function that allows you to create or delete a directory in a Blob Container?

QuentinCG commented 11 months ago

It should be possible.

I'm not sure how to do that, I'll have to check the Azure API to check if it is possible or not.

Anyway, it is possible to create folder from Azure website if you don't need to dynamically add/delete directories.

QuentinCG commented 11 months ago

After google search, you just have to provide the file path to add/get/delete them. There is no notion of "directories" in blob containers API.

https://stackoverflow.com/questions/2619007/microsoft-azure-how-to-create-sub-directory-in-a-blob-container

Example on how to do it:

QNetworkReply downloadFileReply = azure->downloadFile("CONTAINER_NAME_HERE", "subdir0/subdir1/test.txt"); QNetworkReply deleteFileReply = azure->deleteFile("CONTAINER_NAME_HERE", "subdir0/subdir1/test.txt"); // You need to delete all files from subdirectories to delete the subdirectory

Can you please confirm it works ? (If it works, I'll add this in the readme & example)

fverneau commented 11 months ago

Thank you very much ! It works very fine. For information, when we get the list of files, subdirectories are in the filename. Example : "AccessTier : Hot" "AccessTierInferred : true" "BlobType : BlockBlob" "Cache-Control : " "Content-CRC64 : " "Content-Disposition : " "Content-Encoding : " "Content-Language : " "Content-Length : 18" "Content-MD5 : 9s7i09PJy9SQk4XtP0Y6Lw==" "Content-Type : application/octet-stream" "Creation-Time : Wed, 08 Nov 2023 12:42:42 GMT" "Etag : 0x8DBE058335F8012" "Last-Modified : Wed, 08 Nov 2023 12:42:42 GMT" "LeaseState : available" "LeaseStatus : unlocked" "Name : dir01/test_fv.txt" "OrMetadata : " "ServerEncrypted : true"

QuentinCG commented 11 months ago

I added example in readme, thanks