Mercurial > hg > orthanc-object-storage
comparison Azure/AzureBlobStoragePlugin.cpp @ 48:ff113c3561c5
coding style + doc
author | Alain Mazy <am@osimis.io> |
---|---|
date | Fri, 02 Apr 2021 09:46:41 +0200 |
parents | 1691da4ae9c3 |
children | b922ae86bbe1 |
comparison
equal
deleted
inserted
replaced
47:1691da4ae9c3 | 48:ff113c3561c5 |
---|---|
160 const char* AzureBlobStoragePluginFactory::GetStoragePluginName() | 160 const char* AzureBlobStoragePluginFactory::GetStoragePluginName() |
161 { | 161 { |
162 return "Azure Blob Storage"; | 162 return "Azure Blob Storage"; |
163 } | 163 } |
164 | 164 |
165 bool isSasTokenAccountLevel(utility::string_t sasToken) | 165 bool IsSasTokenAccountLevel(utility::string_t sasToken) |
166 { | 166 { |
167 // Use cpprestsdk's utility::string_t here since the expected argument is the return value of | 167 // Use cpprestsdk's utility::string_t here since the expected argument is the return value of |
168 // as::storage_credentials::sas_token(), which is type utility::string_t | 168 // as::storage_credentials::sas_token(), which is type utility::string_t |
169 size_t newIdx = 0; | 169 size_t newIdx = 0; |
170 size_t prevIdx = 0; | 170 size_t prevIdx = 0; |
171 while ((newIdx = sasToken.find('&', prevIdx)) != utility::string_t::npos) | 171 while ((newIdx = sasToken.find('&', prevIdx)) != utility::string_t::npos) |
172 { | 172 { |
173 utility::string_t kvpair = sasToken.substr(prevIdx, newIdx-prevIdx); | 173 utility::string_t kvpair = sasToken.substr(prevIdx, newIdx - prevIdx); |
174 prevIdx = newIdx + 1; // start next time from char after '&' | 174 prevIdx = newIdx + 1; // start next time from char after '&' |
175 | 175 |
176 size_t equalsIdx = kvpair.find('='); | 176 size_t equalsIdx = kvpair.find('='); |
177 utility::string_t key = kvpair.substr(0, equalsIdx); | 177 utility::string_t key = kvpair.substr(0, equalsIdx); |
178 if (key == "srt") // only account SAS has this parameter | 178 if (key == "srt") // only account SAS has this parameter |
272 // blobContainer.create_if_not_exists() throws an error if a service SAS (for a blob container) | 272 // blobContainer.create_if_not_exists() throws an error if a service SAS (for a blob container) |
273 // was used in the connectionString. | 273 // was used in the connectionString. |
274 // Only allow the use of this function when using storage account-level credentials, whether | 274 // Only allow the use of this function when using storage account-level credentials, whether |
275 // through accountName/accountKey combo or account SAS. | 275 // through accountName/accountKey combo or account SAS. |
276 if ((storageAccount.credentials().is_account_key() || | 276 if ((storageAccount.credentials().is_account_key() || |
277 (storageAccount.credentials().is_sas() && isSasTokenAccountLevel(storageAccount.credentials().sas_token()))) | 277 (storageAccount.credentials().is_sas() && IsSasTokenAccountLevel(storageAccount.credentials().sas_token()))) |
278 && createContainerIfNotExists) | 278 && createContainerIfNotExists) |
279 { | 279 { |
280 // Return value is true if the container did not exist and was successfully created. | 280 // Return value is true if the container did not exist and was successfully created. |
281 bool containerCreated = blobContainer.create_if_not_exists(); | 281 bool containerCreated = blobContainer.create_if_not_exists(); |
282 | 282 |