Код: Выделить всё
std::string crypto_GenerateSasToken(
const std::string& permissions,
const std::string& blobName,
const std::string& accessKey,
const std::string& containerName,
const std::string& accountName)
{
// Define SAS token parameters
auto currentTime = std::chrono::system_clock::now();
auto currentTimeSeconds = std::chrono::duration_cast(currentTime.time_since_epoch());
auto expirationTime = currentTimeSeconds + std::chrono::minutes(120);
// Convert time to ISO 8601 format
std::string signedStart = TimePointToString(currentTimeSeconds);
std::string signedExpiry = TimePointToString(expirationTime);
// Define other SAS parameters
std::string signedPermissions = permissions;
std::string signedService = (blobName.empty()) ? "c" : "b"; // 'c' for container, 'b' for blob
std::string signedProtocol = "https";
std::string signedVersion = "2022-11-02";
std::string signedResourceType = ""; // Specifies the resource type (s, c, o for service, container, or object).
// Create canonicalized resource
std::string canonicalizedResource;
if (blobName.empty()) {
// Use container-level resource if blobName is empty
canonicalizedResource = "/blob/" + accountName + "/" + containerName;
} else {
// Use blob-level resource if blobName is not empty
canonicalizedResource = "/blob/" + accountName + "/" + containerName + "/" + blobName;
}
// Construct the string to sign
std::ostringstream stringToSign;
stringToSign
Подробнее здесь: [url]https://stackoverflow.com/questions/79215747/unable-to-generate-a-valid-azure-storage-sas-token-in-cpp-updated-code[/url]