comparison Azure/AzureBlobStoragePlugin.cpp @ 89:62752402edbb

azure build for Windows platform
author Alain Mazy <alain@mazy.be>
date Mon, 28 Nov 2022 14:57:54 +0100
parents e29987d80ecf
children 9b2a76fe987a
comparison
equal deleted inserted replaced
88:43c2644e55a4 89:62752402edbb
24 #include <boost/lexical_cast.hpp> 24 #include <boost/lexical_cast.hpp>
25 #include <boost/algorithm/string.hpp> 25 #include <boost/algorithm/string.hpp>
26 #include "cpprest/rawptrstream.h" 26 #include "cpprest/rawptrstream.h"
27 #include "cpprest/details/basic_types.h" 27 #include "cpprest/details/basic_types.h"
28 28
29
30 // Create aliases to make the code easier to read. 29 // Create aliases to make the code easier to read.
31 namespace as = azure::storage; 30 namespace as = azure::storage;
32 31
33 class AzureBlobStoragePlugin : public BaseStorage 32 class AzureBlobStoragePlugin : public BaseStorage
34 { 33 {
176 } 175 }
177 176
178 bool IsSasTokenAccountLevel(utility::string_t sasToken) 177 bool IsSasTokenAccountLevel(utility::string_t sasToken)
179 { 178 {
180 // Use cpprestsdk's utility::string_t here since the expected argument is the return value of 179 // Use cpprestsdk's utility::string_t here since the expected argument is the return value of
181 // as::storage_credentials::sas_token(), which is type utility::string_t 180 // as::storage_credentials::sas_token(), which is type utility::string_t (which is a std::wstring on Windows and a std::string on Linux)
182 size_t newIdx = 0; 181 size_t newIdx = 0;
183 size_t prevIdx = 0; 182 size_t prevIdx = 0;
184 while ((newIdx = sasToken.find('&', prevIdx)) != utility::string_t::npos) 183 while ((newIdx = sasToken.find('&', prevIdx)) != utility::string_t::npos)
185 { 184 {
186 utility::string_t kvpair = sasToken.substr(prevIdx, newIdx - prevIdx); 185 utility::string_t kvpair = sasToken.substr(prevIdx, newIdx - prevIdx);
187 prevIdx = newIdx + 1; // start next time from char after '&' 186 prevIdx = newIdx + 1; // start next time from char after '&'
188 187
189 size_t equalsIdx = kvpair.find('='); 188 size_t equalsIdx = kvpair.find('=');
190 utility::string_t key = kvpair.substr(0, equalsIdx); 189 utility::string_t key = kvpair.substr(0, equalsIdx);
191 if (key == "srt") // only account SAS has this parameter 190 #ifdef WIN32
191 const wchar_t* srt = L"srt";
192 #else
193 const char* srt = "srt";
194 #endif
195 // if (key == utility::string_t(srt, srt + strlen(srt))) // only account SAS has this parameter
196 if (key == srt) // only account SAS has this parameter
192 return true; 197 return true;
198
193 } 199 }
194 200
195 return false; 201 return false;
196 } 202 }
197 203