From a302ca62e8ac17ba31f522fa4789643a0ef5cb9a Mon Sep 17 00:00:00 2001 From: kambizzandi Date: Mon, 5 Sep 2022 15:24:01 +0430 Subject: [PATCH 1/2] working on s3 bug --- Interfaces/ObjectStorage/Gateways/gtwAWSS3.cpp | 11 ++++++++--- Interfaces/ObjectStorage/Gateways/gtwAWSS3.h | 10 +++++++--- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/Interfaces/ObjectStorage/Gateways/gtwAWSS3.cpp b/Interfaces/ObjectStorage/Gateways/gtwAWSS3.cpp index 01e905b4..7dfc2e04 100644 --- a/Interfaces/ObjectStorage/Gateways/gtwAWSS3.cpp +++ b/Interfaces/ObjectStorage/Gateways/gtwAWSS3.cpp @@ -49,6 +49,10 @@ bool gtwAWSS3::storeFile( << "]" ); + TargomanLogDebug(5, "*** gtwAWSS3::storeFile: #" << __LINE__ << "QFile::exists"); + if (QFile::exists(_fullFileName) == false) + throw exTargomanBase(QString("File %1 not found").arg(_fullFileName)); + // QString Bucket = _uploadGateway.ugwMetaInfo[AWSS3MetaInfoJsonKey::Bucket].toString(); // QString EndpointUrl = _uploadGateway.ugwMetaInfo[AWSS3MetaInfoJsonKey::EndpointUrl].toString(); @@ -101,8 +105,9 @@ bool gtwAWSS3::storeFile( TargomanLogDebug(5, "*** gtwAWSS3::storeFile: #" << __LINE__); Request.SetBucket(_uploadGateway.ugwBucket.toStdString()); - TargomanLogDebug(5, "*** gtwAWSS3::storeFile: #" << __LINE__); - Request.SetKey(QString("%1/%2").arg(_path).arg(_fileName).toStdString()); + QString Key = QString("%1/%2").arg(_path).arg(_fileName); + TargomanLogDebug(5, "*** gtwAWSS3::storeFile: #" << __LINE__ << Key); + Request.SetKey(Key.toStdString()); TargomanLogDebug(5, "*** gtwAWSS3::storeFile: #" << __LINE__); Request.SetACL(S3::Model::ObjectCannedACL::public_read); @@ -117,7 +122,7 @@ bool gtwAWSS3::storeFile( Request.SetBody(InputData); //---------------------------------------- - TargomanLogDebug(5, "*** gtwAWSS3::storeFile: #" << __LINE__); + TargomanLogDebug(5, "*** gtwAWSS3::storeFile: #" << __LINE__ << "S3Client.PutObject"); S3::Model::PutObjectOutcome Outcome = S3Client.PutObject(Request); TargomanLogDebug(5, "*** gtwAWSS3::storeFile: #" << __LINE__); diff --git a/Interfaces/ObjectStorage/Gateways/gtwAWSS3.h b/Interfaces/ObjectStorage/Gateways/gtwAWSS3.h index 5df9185e..4ba387bc 100644 --- a/Interfaces/ObjectStorage/Gateways/gtwAWSS3.h +++ b/Interfaces/ObjectStorage/Gateways/gtwAWSS3.h @@ -47,14 +47,18 @@ using namespace Aws; 15.2) zypper ar -no-gpgcheck https://download.opensuse.org/repositories/home:/targoman/openSUSE_Leap_15.2/home:targoman.repo 15.3) zypper ar -no-gpgcheck https://download.opensuse.org/repositories/home:/targoman/15.3/home:targoman.repo -zypper in aws-sdk-cpp-s3-devel +- zypper in aws-sdk-cpp-s3-devel +- OR +- zypper in aws-sdk-cpp-s3 */ /** installing AmazonAWS S3 from source ************************************************************ git clone --recurse-submodules https://github.com/aws/aws-sdk-cpp mkdir aws-build.s3 cd aws-build.s3 -cmake ../aws-sdk-cpp -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_PREFIX_PATH=/usr -DBUILD_ONLY="s3" +- cmake ../aws-sdk-cpp -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_PREFIX_PATH=/usr -DBUILD_ONLY="s3" +- OR +- cmake ../aws-sdk-cpp -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_PREFIX_PATH=/usr -DBUILD_ONLY="s3" make sudo make install */ @@ -75,7 +79,7 @@ struct __static_s3_initializer__ { //An instance of Aws::SDKOptions is passed to the Aws::InitAPI and //Aws::ShutdownAPI methods. The same instance should be sent to both methods. #ifdef QT_DEBUG - options.loggingOptions.logLevel = Utils::Logging::LogLevel::Debug; + options.loggingOptions.logLevel = Utils::Logging::LogLevel::Trace; #else options.loggingOptions.logLevel = Utils::Logging::LogLevel::Off; #endif From 14f1920c2b97ed65be153256c2b54e9c1d5f1de5 Mon Sep 17 00:00:00 2001 From: kambizzandi Date: Mon, 5 Sep 2022 15:32:38 +0430 Subject: [PATCH 2/2] make gateway name unique --- ...2_Interfaces_ObjectStorage_make_gateway_name_unique.sql | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 Interfaces/migrations/objectstorage/db/m20220905_153042_Interfaces_ObjectStorage_make_gateway_name_unique.sql diff --git a/Interfaces/migrations/objectstorage/db/m20220905_153042_Interfaces_ObjectStorage_make_gateway_name_unique.sql b/Interfaces/migrations/objectstorage/db/m20220905_153042_Interfaces_ObjectStorage_make_gateway_name_unique.sql new file mode 100644 index 00000000..395e1503 --- /dev/null +++ b/Interfaces/migrations/objectstorage/db/m20220905_153042_Interfaces_ObjectStorage_make_gateway_name_unique.sql @@ -0,0 +1,7 @@ +/* Migration File: m20220905_153042_Interfaces_ObjectStorage_make_gateway_name_unique.sql */ +/* CAUTION: don't forget to use {{dbprefix}} for schemas */ + +USE `{{dbprefix}}{{Schema}}`; + +ALTER TABLE `tblUploadGateways` + ADD UNIQUE INDEX `ugwName` (`ugwName`);