Mercurial > hg > orthanc-object-storage
changeset 27:e1f52b851827
Added "VirtualAddressing" configuration option in the AWS S3 plugin (for compatibility with minio)
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Mon, 07 Sep 2020 17:16:38 +0200 |
parents | 471eaf5c5d39 |
children | 318c1442d9bd |
files | Aws/AwsS3StoragePlugin.cpp Common/StoragePlugin.cpp NEWS |
diffstat | 3 files changed, 51 insertions(+), 37 deletions(-) [+] |
line wrap: on
line diff
--- a/Aws/AwsS3StoragePlugin.cpp Mon Sep 07 16:00:59 2020 +0200 +++ b/Aws/AwsS3StoragePlugin.cpp Mon Sep 07 17:16:38 2020 +0200 @@ -226,7 +226,8 @@ std::string endpoint = pluginSection.GetStringValue("Endpoint", ""); unsigned int connectTimeout = pluginSection.GetUnsignedIntegerValue("ConnectTimeout", 30); unsigned int requestTimeout = pluginSection.GetUnsignedIntegerValue("RequestTimeout", 1200); - + bool virtualAddressing = pluginSection.GetBooleanValue("VirtualAddressing", true); + try { Aws::SDKOptions options; @@ -238,13 +239,14 @@ configuration.scheme = Aws::Http::Scheme::HTTPS; configuration.connectTimeoutMs = connectTimeout * 1000; configuration.requestTimeoutMs = requestTimeout * 1000; + configuration.httpRequestTimeoutMs = requestTimeout * 1000; if (!endpoint.empty()) { configuration.endpointOverride = endpoint.c_str(); } - Aws::S3::S3Client client(credentials, configuration); + Aws::S3::S3Client client(credentials, configuration, Aws::Client::AWSAuthV4Signer::PayloadSigningPolicy::Never, virtualAddressing); OrthancPlugins::LogInfo("AWS S3 storage initialized");
--- a/Common/StoragePlugin.cpp Mon Sep 07 16:00:59 2020 +0200 +++ b/Common/StoragePlugin.cpp Mon Sep 07 17:16:38 2020 +0200 @@ -301,52 +301,60 @@ return -1; } - plugin.reset(StoragePluginFactory::CreateStoragePlugin(orthancConfig)); - - if (plugin.get() == nullptr) + try { - return -1; - } - - const char* pluginSectionName = plugin->GetConfigurationSectionName(); - static const char* const ENCRYPTION_SECTION = "StorageEncryption"; + plugin.reset(StoragePluginFactory::CreateStoragePlugin(orthancConfig)); - if (orthancConfig.IsSection(pluginSectionName)) - { - OrthancPlugins::OrthancConfiguration pluginSection; - orthancConfig.GetSection(pluginSection, pluginSectionName); - - migrationFromFileSystemEnabled = pluginSection.GetBooleanValue("MigrationFromFileSystemEnabled", false); - - if (migrationFromFileSystemEnabled) + if (plugin.get() == nullptr) { - fileSystemRootPath = orthancConfig.GetStringValue("StorageDirectory", "OrthancStorageNotDefined"); - OrthancPlugins::LogWarning(std::string(StoragePluginFactory::GetStoragePluginName()) + ": migration from file system enabled, source: " + fileSystemRootPath); + return -1; } - objectsRootPath = pluginSection.GetStringValue("RootPath", std::string()); - plugin->SetRootPath(objectsRootPath); + const char* pluginSectionName = plugin->GetConfigurationSectionName(); + static const char* const ENCRYPTION_SECTION = "StorageEncryption"; - if (pluginSection.IsSection(ENCRYPTION_SECTION)) + if (orthancConfig.IsSection(pluginSectionName)) { - OrthancPlugins::OrthancConfiguration cryptoSection; - pluginSection.GetSection(cryptoSection, ENCRYPTION_SECTION); + OrthancPlugins::OrthancConfiguration pluginSection; + orthancConfig.GetSection(pluginSection, pluginSectionName); + + migrationFromFileSystemEnabled = pluginSection.GetBooleanValue("MigrationFromFileSystemEnabled", false); + + if (migrationFromFileSystemEnabled) + { + fileSystemRootPath = orthancConfig.GetStringValue("StorageDirectory", "OrthancStorageNotDefined"); + OrthancPlugins::LogWarning(std::string(StoragePluginFactory::GetStoragePluginName()) + ": migration from file system enabled, source: " + fileSystemRootPath); + } + + objectsRootPath = pluginSection.GetStringValue("RootPath", std::string()); + plugin->SetRootPath(objectsRootPath); - crypto.reset(EncryptionConfigurator::CreateEncryptionHelpers(cryptoSection)); - cryptoEnabled = crypto.get() != nullptr; + if (pluginSection.IsSection(ENCRYPTION_SECTION)) + { + OrthancPlugins::OrthancConfiguration cryptoSection; + pluginSection.GetSection(cryptoSection, ENCRYPTION_SECTION); + + crypto.reset(EncryptionConfigurator::CreateEncryptionHelpers(cryptoSection)); + cryptoEnabled = crypto.get() != nullptr; + } + + if (cryptoEnabled) + { + OrthancPlugins::LogWarning(std::string(StoragePluginFactory::GetStoragePluginName()) + ": client-side encryption is enabled"); + } + else + { + OrthancPlugins::LogWarning(std::string(StoragePluginFactory::GetStoragePluginName()) + ": client-side encryption is disabled"); + } } - if (cryptoEnabled) - { - OrthancPlugins::LogWarning(std::string(StoragePluginFactory::GetStoragePluginName()) + ": client-side encryption is enabled"); - } - else - { - OrthancPlugins::LogWarning(std::string(StoragePluginFactory::GetStoragePluginName()) + ": client-side encryption is disabled"); - } + OrthancPluginRegisterStorageArea(context, StorageCreate, StorageRead, StorageRemove); } - - OrthancPluginRegisterStorageArea(context, StorageCreate, StorageRead, StorageRemove); + catch (Orthanc::OrthancException& e) + { + LOG(ERROR) << "Exception while creating the object storage plugin: " << e.What(); + return -1; + } return 0; }
--- a/NEWS Mon Sep 07 16:00:59 2020 +0200 +++ b/NEWS Mon Sep 07 17:16:38 2020 +0200 @@ -1,6 +1,10 @@ Pending changes in the mainline =============================== +* Allow compilation of the AWS S3 plugin without vcpkg +* Added "VirtualAddressing" configuration option in the AWS S3 plugin (for compatibility with minio) + + 2020-09-07 - v 1.1.0 ====================