Remove unused files from Gems/AWSCore
Signed-off-by: Esteban Papp <81431996+amznestebanpapp@users.noreply.github.com>
This commit is contained in:
@@ -1,3 +0,0 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:bfc2ef8c6dbf2fba078e27e4e94384099e090468e679327dd826a5cbf22b04ed
|
||||
size 1019
|
||||
@@ -1,3 +0,0 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:708b12d41229afab78e0f7d59097ae3de855fea8525a920c5c214fc0ce79f1bd
|
||||
size 1209
|
||||
@@ -1,3 +0,0 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:fab63af9b50790dca25330058e70517987ea8bf11c00f9353dd951ebdbd1dbe5
|
||||
size 5008
|
||||
@@ -49513,106 +49513,6 @@ An Entity can be selected by using the pick button, or by dragging an Entity fro
|
||||
<translation></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>Handler: HttpClientComponentNotificationBus</name>
|
||||
<message id="HANDLER_HTTPCLIENTCOMPONENTNOTIFICATIONBUS_NAME">
|
||||
<source>HANDLER_HTTPCLIENTCOMPONENTNOTIFICATIONBUS_NAME</source>
|
||||
<translation>HttpClientComponentNotificationBus</translation>
|
||||
</message>
|
||||
<message id="HANDLER_HTTPCLIENTCOMPONENTNOTIFICATIONBUS_TOOLTIP">
|
||||
<source>HANDLER_HTTPCLIENTCOMPONENTNOTIFICATIONBUS_TOOLTIP</source>
|
||||
<translation></translation>
|
||||
</message>
|
||||
<message id="HANDLER_HTTPCLIENTCOMPONENTNOTIFICATIONBUS_CATEGORY">
|
||||
<source>HANDLER_HTTPCLIENTCOMPONENTNOTIFICATIONBUS_CATEGORY</source>
|
||||
<translation type="unfinished">Networking</translation>
|
||||
</message>
|
||||
<message id="HANDLER_HTTPCLIENTCOMPONENTNOTIFICATIONBUS_ONHTTPREQUESTSUCCESS_NAME">
|
||||
<source>HANDLER_HTTPCLIENTCOMPONENTNOTIFICATIONBUS_ONHTTPREQUESTSUCCESS_NAME</source>
|
||||
<comment>Class/Bus: HttpClientComponentNotificationBus Event/Method: OnHttpRequestSuccess</comment>
|
||||
<translation>OnHttpRequestSuccess</translation>
|
||||
</message>
|
||||
<message id="HANDLER_HTTPCLIENTCOMPONENTNOTIFICATIONBUS_ONHTTPREQUESTSUCCESS_TOOLTIP">
|
||||
<source>HANDLER_HTTPCLIENTCOMPONENTNOTIFICATIONBUS_ONHTTPREQUESTSUCCESS_TOOLTIP</source>
|
||||
<translation></translation>
|
||||
</message>
|
||||
<message id="HANDLER_HTTPCLIENTCOMPONENTNOTIFICATIONBUS_ONHTTPREQUESTSUCCESS_CATEGORY">
|
||||
<source>HANDLER_HTTPCLIENTCOMPONENTNOTIFICATIONBUS_ONHTTPREQUESTSUCCESS_CATEGORY</source>
|
||||
<translation></translation>
|
||||
</message>
|
||||
<message id="HANDLER_HTTPCLIENTCOMPONENTNOTIFICATIONBUS_ONHTTPREQUESTSUCCESS_OUT_NAME">
|
||||
<source>HANDLER_HTTPCLIENTCOMPONENTNOTIFICATIONBUS_ONHTTPREQUESTSUCCESS_OUT_NAME</source>
|
||||
<translation></translation>
|
||||
</message>
|
||||
<message id="HANDLER_HTTPCLIENTCOMPONENTNOTIFICATIONBUS_ONHTTPREQUESTSUCCESS_OUT_TOOLTIP">
|
||||
<source>HANDLER_HTTPCLIENTCOMPONENTNOTIFICATIONBUS_ONHTTPREQUESTSUCCESS_OUT_TOOLTIP</source>
|
||||
<translation></translation>
|
||||
</message>
|
||||
<message id="HANDLER_HTTPCLIENTCOMPONENTNOTIFICATIONBUS_ONHTTPREQUESTSUCCESS_IN_NAME">
|
||||
<source>HANDLER_HTTPCLIENTCOMPONENTNOTIFICATIONBUS_ONHTTPREQUESTSUCCESS_IN_NAME</source>
|
||||
<translation></translation>
|
||||
</message>
|
||||
<message id="HANDLER_HTTPCLIENTCOMPONENTNOTIFICATIONBUS_ONHTTPREQUESTSUCCESS_IN_TOOLTIP">
|
||||
<source>HANDLER_HTTPCLIENTCOMPONENTNOTIFICATIONBUS_ONHTTPREQUESTSUCCESS_IN_TOOLTIP</source>
|
||||
<translation></translation>
|
||||
</message>
|
||||
<message id="HANDLER_HTTPCLIENTCOMPONENTNOTIFICATIONBUS_ONHTTPREQUESTSUCCESS_OUTPUT0_NAME">
|
||||
<source>HANDLER_HTTPCLIENTCOMPONENTNOTIFICATIONBUS_ONHTTPREQUESTSUCCESS_OUTPUT0_NAME</source>
|
||||
<comment>Simple Type: Number C++ Type: int</comment>
|
||||
<translation></translation>
|
||||
</message>
|
||||
<message id="HANDLER_HTTPCLIENTCOMPONENTNOTIFICATIONBUS_ONHTTPREQUESTSUCCESS_OUTPUT0_TOOLTIP">
|
||||
<source>HANDLER_HTTPCLIENTCOMPONENTNOTIFICATIONBUS_ONHTTPREQUESTSUCCESS_OUTPUT0_TOOLTIP</source>
|
||||
<translation></translation>
|
||||
</message>
|
||||
<message id="HANDLER_HTTPCLIENTCOMPONENTNOTIFICATIONBUS_ONHTTPREQUESTSUCCESS_OUTPUT1_NAME">
|
||||
<source>HANDLER_HTTPCLIENTCOMPONENTNOTIFICATIONBUS_ONHTTPREQUESTSUCCESS_OUTPUT1_NAME</source>
|
||||
<comment>Simple Type: String C++ Type: AZStd::basic_string<char, AZStd::char_traits<char>, allocator></comment>
|
||||
<translation></translation>
|
||||
</message>
|
||||
<message id="HANDLER_HTTPCLIENTCOMPONENTNOTIFICATIONBUS_ONHTTPREQUESTSUCCESS_OUTPUT1_TOOLTIP">
|
||||
<source>HANDLER_HTTPCLIENTCOMPONENTNOTIFICATIONBUS_ONHTTPREQUESTSUCCESS_OUTPUT1_TOOLTIP</source>
|
||||
<translation></translation>
|
||||
</message>
|
||||
<message id="HANDLER_HTTPCLIENTCOMPONENTNOTIFICATIONBUS_ONHTTPREQUESTFAILURE_NAME">
|
||||
<source>HANDLER_HTTPCLIENTCOMPONENTNOTIFICATIONBUS_ONHTTPREQUESTFAILURE_NAME</source>
|
||||
<comment>Class/Bus: HttpClientComponentNotificationBus Event/Method: OnHttpRequestFailure</comment>
|
||||
<translation>OnHttpRequestFailure</translation>
|
||||
</message>
|
||||
<message id="HANDLER_HTTPCLIENTCOMPONENTNOTIFICATIONBUS_ONHTTPREQUESTFAILURE_TOOLTIP">
|
||||
<source>HANDLER_HTTPCLIENTCOMPONENTNOTIFICATIONBUS_ONHTTPREQUESTFAILURE_TOOLTIP</source>
|
||||
<translation></translation>
|
||||
</message>
|
||||
<message id="HANDLER_HTTPCLIENTCOMPONENTNOTIFICATIONBUS_ONHTTPREQUESTFAILURE_CATEGORY">
|
||||
<source>HANDLER_HTTPCLIENTCOMPONENTNOTIFICATIONBUS_ONHTTPREQUESTFAILURE_CATEGORY</source>
|
||||
<translation></translation>
|
||||
</message>
|
||||
<message id="HANDLER_HTTPCLIENTCOMPONENTNOTIFICATIONBUS_ONHTTPREQUESTFAILURE_OUT_NAME">
|
||||
<source>HANDLER_HTTPCLIENTCOMPONENTNOTIFICATIONBUS_ONHTTPREQUESTFAILURE_OUT_NAME</source>
|
||||
<translation></translation>
|
||||
</message>
|
||||
<message id="HANDLER_HTTPCLIENTCOMPONENTNOTIFICATIONBUS_ONHTTPREQUESTFAILURE_OUT_TOOLTIP">
|
||||
<source>HANDLER_HTTPCLIENTCOMPONENTNOTIFICATIONBUS_ONHTTPREQUESTFAILURE_OUT_TOOLTIP</source>
|
||||
<translation></translation>
|
||||
</message>
|
||||
<message id="HANDLER_HTTPCLIENTCOMPONENTNOTIFICATIONBUS_ONHTTPREQUESTFAILURE_IN_NAME">
|
||||
<source>HANDLER_HTTPCLIENTCOMPONENTNOTIFICATIONBUS_ONHTTPREQUESTFAILURE_IN_NAME</source>
|
||||
<translation></translation>
|
||||
</message>
|
||||
<message id="HANDLER_HTTPCLIENTCOMPONENTNOTIFICATIONBUS_ONHTTPREQUESTFAILURE_IN_TOOLTIP">
|
||||
<source>HANDLER_HTTPCLIENTCOMPONENTNOTIFICATIONBUS_ONHTTPREQUESTFAILURE_IN_TOOLTIP</source>
|
||||
<translation></translation>
|
||||
</message>
|
||||
<message id="HANDLER_HTTPCLIENTCOMPONENTNOTIFICATIONBUS_ONHTTPREQUESTFAILURE_OUTPUT0_NAME">
|
||||
<source>HANDLER_HTTPCLIENTCOMPONENTNOTIFICATIONBUS_ONHTTPREQUESTFAILURE_OUTPUT0_NAME</source>
|
||||
<comment>Simple Type: Number C++ Type: int</comment>
|
||||
<translation></translation>
|
||||
</message>
|
||||
<message id="HANDLER_HTTPCLIENTCOMPONENTNOTIFICATIONBUS_ONHTTPREQUESTFAILURE_OUTPUT0_TOOLTIP">
|
||||
<source>HANDLER_HTTPCLIENTCOMPONENTNOTIFICATIONBUS_ONHTTPREQUESTFAILURE_OUTPUT0_TOOLTIP</source>
|
||||
<translation></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>Handler: InputEventNotificationBus</name>
|
||||
<message id="HANDLER_INPUTEVENTNOTIFICATIONBUS_NAME">
|
||||
@@ -79046,77 +78946,6 @@ The element is removed from its current parent and added as a child of the new p
|
||||
<translation></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>EBus: HttpClientComponentRequestBus</name>
|
||||
<message id="HTTPCLIENTCOMPONENTREQUESTBUS_NAME">
|
||||
<source>HTTPCLIENTCOMPONENTREQUESTBUS_NAME</source>
|
||||
<translation>HttpClientComponentRequestBus</translation>
|
||||
</message>
|
||||
<message id="HTTPCLIENTCOMPONENTREQUESTBUS_TOOLTIP">
|
||||
<source>HTTPCLIENTCOMPONENTREQUESTBUS_TOOLTIP</source>
|
||||
<translation></translation>
|
||||
</message>
|
||||
<message id="HTTPCLIENTCOMPONENTREQUESTBUS_CATEGORY">
|
||||
<source>HTTPCLIENTCOMPONENTREQUESTBUS_CATEGORY</source>
|
||||
<translation type="unfinished">Networking</translation>
|
||||
</message>
|
||||
<message id="HTTPCLIENTCOMPONENTREQUESTBUS_MAKEHTTPREQUEST_NAME">
|
||||
<source>HTTPCLIENTCOMPONENTREQUESTBUS_MAKEHTTPREQUEST_NAME</source>
|
||||
<comment>Class/Bus: HttpClientComponentRequestBus Event/Method: MakeHttpRequest</comment>
|
||||
<translation>MakeHttpRequest</translation>
|
||||
</message>
|
||||
<message id="HTTPCLIENTCOMPONENTREQUESTBUS_MAKEHTTPREQUEST_TOOLTIP">
|
||||
<source>HTTPCLIENTCOMPONENTREQUESTBUS_MAKEHTTPREQUEST_TOOLTIP</source>
|
||||
<translation></translation>
|
||||
</message>
|
||||
<message id="HTTPCLIENTCOMPONENTREQUESTBUS_MAKEHTTPREQUEST_CATEGORY">
|
||||
<source>HTTPCLIENTCOMPONENTREQUESTBUS_MAKEHTTPREQUEST_CATEGORY</source>
|
||||
<translation></translation>
|
||||
</message>
|
||||
<message id="HTTPCLIENTCOMPONENTREQUESTBUS_MAKEHTTPREQUEST_OUT_NAME">
|
||||
<source>HTTPCLIENTCOMPONENTREQUESTBUS_MAKEHTTPREQUEST_OUT_NAME</source>
|
||||
<translation></translation>
|
||||
</message>
|
||||
<message id="HTTPCLIENTCOMPONENTREQUESTBUS_MAKEHTTPREQUEST_OUT_TOOLTIP">
|
||||
<source>HTTPCLIENTCOMPONENTREQUESTBUS_MAKEHTTPREQUEST_OUT_TOOLTIP</source>
|
||||
<translation></translation>
|
||||
</message>
|
||||
<message id="HTTPCLIENTCOMPONENTREQUESTBUS_MAKEHTTPREQUEST_IN_NAME">
|
||||
<source>HTTPCLIENTCOMPONENTREQUESTBUS_MAKEHTTPREQUEST_IN_NAME</source>
|
||||
<translation></translation>
|
||||
</message>
|
||||
<message id="HTTPCLIENTCOMPONENTREQUESTBUS_MAKEHTTPREQUEST_IN_TOOLTIP">
|
||||
<source>HTTPCLIENTCOMPONENTREQUESTBUS_MAKEHTTPREQUEST_IN_TOOLTIP</source>
|
||||
<translation></translation>
|
||||
</message>
|
||||
<message id="HTTPCLIENTCOMPONENTREQUESTBUS_MAKEHTTPREQUEST_PARAM0_NAME">
|
||||
<source>HTTPCLIENTCOMPONENTREQUESTBUS_MAKEHTTPREQUEST_PARAM0_NAME</source>
|
||||
<comment>Simple Type: String C++ Type: AZStd::basic_string<char, AZStd::char_traits<char>, allocator></comment>
|
||||
<translation></translation>
|
||||
</message>
|
||||
<message id="HTTPCLIENTCOMPONENTREQUESTBUS_MAKEHTTPREQUEST_PARAM0_TOOLTIP">
|
||||
<source>HTTPCLIENTCOMPONENTREQUESTBUS_MAKEHTTPREQUEST_PARAM0_TOOLTIP</source>
|
||||
<translation></translation>
|
||||
</message>
|
||||
<message id="HTTPCLIENTCOMPONENTREQUESTBUS_MAKEHTTPREQUEST_PARAM1_NAME">
|
||||
<source>HTTPCLIENTCOMPONENTREQUESTBUS_MAKEHTTPREQUEST_PARAM1_NAME</source>
|
||||
<comment>Simple Type: String C++ Type: AZStd::basic_string<char, AZStd::char_traits<char>, allocator></comment>
|
||||
<translation></translation>
|
||||
</message>
|
||||
<message id="HTTPCLIENTCOMPONENTREQUESTBUS_MAKEHTTPREQUEST_PARAM1_TOOLTIP">
|
||||
<source>HTTPCLIENTCOMPONENTREQUESTBUS_MAKEHTTPREQUEST_PARAM1_TOOLTIP</source>
|
||||
<translation></translation>
|
||||
</message>
|
||||
<message id="HTTPCLIENTCOMPONENTREQUESTBUS_MAKEHTTPREQUEST_PARAM2_NAME">
|
||||
<source>HTTPCLIENTCOMPONENTREQUESTBUS_MAKEHTTPREQUEST_PARAM2_NAME</source>
|
||||
<comment>Simple Type: String C++ Type: AZStd::basic_string<char, AZStd::char_traits<char>, allocator></comment>
|
||||
<translation></translation>
|
||||
</message>
|
||||
<message id="HTTPCLIENTCOMPONENTREQUESTBUS_MAKEHTTPREQUEST_PARAM2_TOOLTIP">
|
||||
<source>HTTPCLIENTCOMPONENTREQUESTBUS_MAKEHTTPREQUEST_PARAM2_TOOLTIP</source>
|
||||
<translation></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>Handler: AWSBehaviorURLNotificationsBus</name>
|
||||
<message id="HANDLER_AWSBEHAVIORURLNOTIFICATIONSBUS_NAME">
|
||||
|
||||
@@ -1,69 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) Contributors to the Open 3D Engine Project.
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <AzCore/Component/Component.h>
|
||||
#include <AzCore/Component/ComponentBus.h>
|
||||
#include <AzCore/EBus/EBus.h>
|
||||
#include <AzCore/Memory/SystemAllocator.h>
|
||||
#include <AzCore/Serialization/EditContext.h>
|
||||
#include <AzCore/Serialization/SerializeContext.h>
|
||||
|
||||
|
||||
|
||||
#include <Framework/AWSApiClientJob.h>
|
||||
|
||||
|
||||
namespace AWSCore
|
||||
{
|
||||
/////////////////////////////////////////////
|
||||
// EBus Definitions
|
||||
/////////////////////////////////////////////
|
||||
class HttpClientComponentRequests
|
||||
: public AZ::ComponentBus
|
||||
{
|
||||
public:
|
||||
virtual ~HttpClientComponentRequests() {}
|
||||
virtual void MakeHttpRequest(AZStd::string url, AZStd::string method, AZStd::string jsonBody) {}
|
||||
};
|
||||
|
||||
using HttpClientComponentRequestBus = AZ::EBus<HttpClientComponentRequests>;
|
||||
|
||||
class HttpClientComponentNotifications
|
||||
: public AZ::ComponentBus
|
||||
{
|
||||
public:
|
||||
~HttpClientComponentNotifications() override = default;
|
||||
virtual void OnHttpRequestSuccess(int responseCode, AZStd::string responseBody) {}
|
||||
virtual void OnHttpRequestFailure(int responseCode) {}
|
||||
};
|
||||
|
||||
using HttpClientComponentNotificationBus = AZ::EBus<HttpClientComponentNotifications>;
|
||||
|
||||
/////////////////////////////////////////////
|
||||
// Entity Component
|
||||
/////////////////////////////////////////////
|
||||
class HttpClientComponent
|
||||
: public AZ::Component
|
||||
, public HttpClientComponentRequestBus::Handler
|
||||
{
|
||||
public:
|
||||
AZ_COMPONENT(HttpClientComponent, "{23ECDBDF-129A-4670-B9B4-1E0B541ACD61}");
|
||||
~HttpClientComponent() override = default;
|
||||
|
||||
void Init() override;
|
||||
void Activate() override;
|
||||
void Deactivate() override;
|
||||
|
||||
void MakeHttpRequest(AZStd::string, AZStd::string, AZStd::string) override;
|
||||
|
||||
static void Reflect(AZ::ReflectContext*);
|
||||
};
|
||||
|
||||
} // namespace AWSCore
|
||||
@@ -1,66 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) Contributors to the Open 3D Engine Project.
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <AzCore/Jobs/JobManager.h>
|
||||
#include <AzCore/Jobs/JobFunction.h>
|
||||
|
||||
#include <aws/core/utils/threading/Executor.h>
|
||||
|
||||
namespace AWSCore
|
||||
{
|
||||
|
||||
/// AZ:Job type used by the JobExecuter. It is used call the callback
|
||||
/// function provided by the AWS SDK.
|
||||
using ExecuterJob = AZ::JobFunction<std::function<void()>>;
|
||||
|
||||
/// This class provides a simple alternative to using the the AwsRequestJob,
|
||||
/// AwsApiClientJob, or AwsApiJob classes. Those classes provide configuration
|
||||
/// management and more abstracted usage patterns. With JobExecutor you need
|
||||
/// to do all the configuration management and work directly with the AWS API.
|
||||
///
|
||||
/// An AWS API async executer that uses the AZ::Job system to make AWS service calls.
|
||||
/// To use, set the Aws::Client::ClientConfiguration executor field so it points to
|
||||
/// an instance of this class, then use that client configuration object when creating
|
||||
/// AWS service client objects. This will cause the Async APIs on the AWS service
|
||||
/// client object to use the AZ::Job system to execute the request.
|
||||
class JobExecuter
|
||||
: public Aws::Utils::Threading::Executor
|
||||
{
|
||||
|
||||
public:
|
||||
/// Initialize a JobExecuter object.
|
||||
///
|
||||
/// \param context - The JobContext that will be used to execute the jobs created
|
||||
/// by the JobExecuter.
|
||||
///
|
||||
/// By default the global JobContext is used. However, the AWS SDK currently
|
||||
/// only supports blocking calls, so, to avoid impacting other jobs, it is
|
||||
/// recommended that you create a JobContext with a JobManager dedicated to
|
||||
/// dedicated to processing these jobs. This context can also be used with
|
||||
/// AwsApiCore::HttpJob.
|
||||
JobExecuter(AZ::JobContext* context)
|
||||
: m_context{ context }
|
||||
{
|
||||
}
|
||||
|
||||
protected:
|
||||
AZ::JobContext* m_context;
|
||||
|
||||
/// Called by the AWS SDK to queue a callback for execution.
|
||||
bool SubmitToThread(std::function<void()>&& callback) override
|
||||
{
|
||||
ExecuterJob* job = aznew ExecuterJob(callback, true, m_context);
|
||||
job->Start();
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
} // namespace AWCore
|
||||
|
||||
@@ -1,76 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) Contributors to the Open 3D Engine Project.
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <AzCore/Memory/SystemAllocator.h>
|
||||
#include <AzCore/std/containers/vector.h>
|
||||
#include <AzCore/std/string/string.h>
|
||||
|
||||
namespace AWSCore
|
||||
{
|
||||
/// Class for generating multi-part form data capable of sending files via HTTP POST.
|
||||
/// The current implementation writes the entire contents of the file to an output buffer in a single operation,
|
||||
/// i.e. there is no streaming for large files.
|
||||
/// A stream-based solution would require better bridging of types between CGF and AWS.
|
||||
class MultipartFormData
|
||||
{
|
||||
public:
|
||||
struct ComposeResult
|
||||
{
|
||||
AZStd::string m_content; // Use for the request body
|
||||
AZStd::string m_contentLength; // Use for the 'Content-Length' HTTP header field
|
||||
AZStd::string m_contentType; // Use for the 'Content-Type' HTTP header field
|
||||
};
|
||||
|
||||
public:
|
||||
AZ_CLASS_ALLOCATOR(MultipartFormData, AZ::SystemAllocator, 0);
|
||||
|
||||
/// Add a field/value pair to the form
|
||||
void AddField(AZStd::string name, AZStd::string value);
|
||||
|
||||
/// Add a file's contents to the form
|
||||
void AddFile(AZStd::string fieldName, AZStd::string fileName, const char* path);
|
||||
void AddFileBytes(AZStd::string fieldName, AZStd::string fileName, const void* bytes, size_t length);
|
||||
|
||||
/// Set a custom boundary delimiter to use in the form. This is optional; a random one will be generated normally.
|
||||
void SetCustomBoundary(AZStd::string boundary);
|
||||
|
||||
/// Compose the form's contents and returns those contents along with metadata.
|
||||
ComposeResult ComposeForm();
|
||||
|
||||
private:
|
||||
struct Field
|
||||
{
|
||||
AZStd::string m_fieldName;
|
||||
AZStd::string m_value;
|
||||
};
|
||||
|
||||
struct FileField
|
||||
{
|
||||
AZStd::string m_fieldName;
|
||||
AZStd::string m_fileName;
|
||||
AZStd::vector<char> m_fileData;
|
||||
};
|
||||
|
||||
using Fields = AZStd::vector<Field>;
|
||||
using FileFields = AZStd::vector<FileField>;
|
||||
|
||||
private:
|
||||
void Prepare();
|
||||
size_t EstimateBodySize() const;
|
||||
|
||||
private:
|
||||
AZStd::string m_boundary;
|
||||
AZStd::string m_separator;
|
||||
AZStd::string m_composedBody;
|
||||
Fields m_fields;
|
||||
FileFields m_fileFields;
|
||||
};
|
||||
|
||||
} // namespace AWSCore
|
||||
@@ -1,123 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) Contributors to the Open 3D Engine Project.
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include <AzCore/IO/FileIO.h>
|
||||
#include <Framework/MultipartFormData.h>
|
||||
|
||||
namespace AWSCore
|
||||
{
|
||||
namespace Detail
|
||||
{
|
||||
namespace
|
||||
{
|
||||
const char FIELD_HEADER_FMT[] = "--%s\r\nContent-Disposition: form-data; name=\"%s\"\r\n\r\n";
|
||||
const char FILE_HEADER_FMT[] = "--%s\r\nContent-Disposition: form-data; name=\"%s\"; filename=\"%s\"\r\n\r\n";
|
||||
const char FOOTER_FMT[] = "--%s--\r\n";
|
||||
const char ENTRY_SEPARATOR[] = "\r\n";
|
||||
}
|
||||
}
|
||||
|
||||
void MultipartFormData::AddField(AZStd::string name, AZStd::string value)
|
||||
{
|
||||
m_fields.emplace_back(Field{ std::move(name), std::move(value) });
|
||||
}
|
||||
|
||||
void MultipartFormData::AddFile(AZStd::string fieldName, AZStd::string fileName, const char* path)
|
||||
{
|
||||
AZ::IO::FileIOBase* fileIO = AZ::IO::FileIOBase::GetDirectInstance();
|
||||
|
||||
AZ::IO::HandleType fileHandle;
|
||||
|
||||
if (fileIO->Open(path, AZ::IO::OpenMode::ModeRead | AZ::IO::OpenMode::ModeBinary, fileHandle)) {
|
||||
m_fileFields.emplace_back(FileField{ std::move(fieldName), std::move(fileName) , AZStd::vector<char>{} });
|
||||
auto destFileBuffer = &m_fileFields.back().m_fileData;
|
||||
AZ::u64 size;
|
||||
if (fileIO->Size(path, size) && size > 0) {
|
||||
destFileBuffer->resize(size);
|
||||
fileIO->Read(fileHandle, &destFileBuffer->at(0), destFileBuffer->size());
|
||||
}
|
||||
}
|
||||
fileIO->Close(fileHandle);
|
||||
}
|
||||
|
||||
void MultipartFormData::AddFileBytes(AZStd::string fieldName, AZStd::string fileName, const void* bytes, size_t length)
|
||||
{
|
||||
m_fileFields.emplace_back(FileField{ std::move(fieldName), std::move(fileName) , AZStd::vector<char>{} });
|
||||
m_fileFields.back().m_fileData.reserve(length);
|
||||
m_fileFields.back().m_fileData.assign(static_cast<const char*>(bytes), static_cast<const char*>(bytes) + length);
|
||||
}
|
||||
|
||||
void MultipartFormData::SetCustomBoundary(AZStd::string boundary)
|
||||
{
|
||||
m_boundary = boundary;
|
||||
}
|
||||
|
||||
void MultipartFormData::Prepare()
|
||||
{
|
||||
if (m_boundary.empty())
|
||||
{
|
||||
char buffer[33];
|
||||
AZ::Uuid::CreateRandom().ToString(buffer, sizeof(buffer), false, false);
|
||||
m_boundary = buffer;
|
||||
}
|
||||
}
|
||||
|
||||
size_t MultipartFormData::EstimateBodySize() const
|
||||
{
|
||||
// Estimate the size of the final string as best we can to avoid unnecessary copies
|
||||
const size_t boundarySize = m_boundary.length();
|
||||
const size_t individualFieldBaseSize = boundarySize + sizeof(Detail::FIELD_HEADER_FMT) + sizeof(Detail::ENTRY_SEPARATOR);
|
||||
const size_t individualFileBaseSize = boundarySize + sizeof(Detail::FILE_HEADER_FMT) + sizeof(Detail::ENTRY_SEPARATOR);
|
||||
size_t estimatedSize = sizeof(Detail::FOOTER_FMT) + boundarySize;
|
||||
|
||||
for (const auto& field : m_fields)
|
||||
{
|
||||
estimatedSize += individualFieldBaseSize + field.m_fieldName.length() + field.m_value.length();
|
||||
}
|
||||
|
||||
for (const auto& fileField : m_fileFields)
|
||||
{
|
||||
estimatedSize += individualFileBaseSize + fileField.m_fieldName.length() + fileField.m_fileName.length() + fileField.m_fileData.size();
|
||||
}
|
||||
|
||||
return estimatedSize;
|
||||
}
|
||||
|
||||
MultipartFormData::ComposeResult MultipartFormData::ComposeForm()
|
||||
{
|
||||
ComposeResult result;
|
||||
Prepare();
|
||||
|
||||
// Build the form body
|
||||
result.m_content.reserve(EstimateBodySize());
|
||||
|
||||
for (const auto& field : m_fields)
|
||||
{
|
||||
result.m_content.append(AZStd::string::format(Detail::FIELD_HEADER_FMT, m_boundary.c_str(), field.m_fieldName.c_str()));
|
||||
result.m_content.append(field.m_value);
|
||||
result.m_content.append(Detail::ENTRY_SEPARATOR);
|
||||
}
|
||||
|
||||
for (const auto& fileField : m_fileFields)
|
||||
{
|
||||
result.m_content.append(AZStd::string::format(Detail::FILE_HEADER_FMT, m_boundary.c_str(), fileField.m_fieldName.c_str(), fileField.m_fileName.c_str()));
|
||||
result.m_content.append(fileField.m_fileData.begin(), fileField.m_fileData.end());
|
||||
result.m_content.append(Detail::ENTRY_SEPARATOR);
|
||||
}
|
||||
|
||||
result.m_content.append(AZStd::string::format(Detail::FOOTER_FMT, m_boundary.c_str()));
|
||||
|
||||
// Populate the metadata
|
||||
result.m_contentLength = AZStd::string::format("%zu", result.m_content.length());
|
||||
result.m_contentType = AZStd::string::format("multipart/form-data; boundary=%s", m_boundary.c_str());
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
} // namespace AWSCore
|
||||
@@ -16,13 +16,10 @@ set(FILES
|
||||
Include/Framework/AWSApiRequestJob.h
|
||||
Include/Framework/AWSApiRequestJobConfig.h
|
||||
Include/Framework/Error.h
|
||||
Include/Framework/HttpClientComponent.h
|
||||
Include/Framework/HttpRequestJob.h
|
||||
Include/Framework/HttpRequestJobConfig.h
|
||||
Include/Framework/JobExecuter.h
|
||||
Include/Framework/JsonObjectHandler.h
|
||||
Include/Framework/JsonWriter.h
|
||||
Include/Framework/MultipartFormData.h
|
||||
Include/Framework/RequestBuilder.h
|
||||
Include/Framework/ServiceClientJob.h
|
||||
Include/Framework/ServiceClientJobConfig.h
|
||||
@@ -61,7 +58,6 @@ set(FILES
|
||||
Source/Framework/HttpRequestJob.cpp
|
||||
Source/Framework/HttpRequestJobConfig.cpp
|
||||
Source/Framework/JsonObjectHandler.cpp
|
||||
Source/Framework/MultipartFormData.cpp
|
||||
Source/Framework/RequestBuilder.cpp
|
||||
Source/Framework/ServiceJob.cpp
|
||||
Source/Framework/ServiceJobConfig.cpp
|
||||
|
||||
Reference in New Issue
Block a user