16 #include <boost/function.hpp> 19 #include <aws/core/Aws.h> 20 #include <aws/core/utils/logging/LogMacros.h> 50 std::lock_guard<std::recursive_mutex> lock(
mutex_);
57 const std::vector<UploadDescription> & upload_descriptions,
58 const std::string & bucket,
59 const boost::function<
void (
const std::vector<UploadDescription>&)>& feedback_callback)
62 std::lock_guard<std::recursive_mutex> lock(
mutex_);
64 return Model::PutObjectOutcome(Aws::Client::AWSError<S3Errors>(S3Errors::INVALID_ACTION,
65 "INVALID_ACTION",
"UploadFiles aborted. UploadFiles request already active.",
false));
69 std::vector<UploadDescription> completed_uploads;
71 Model::PutObjectResult default_result;
72 Model::PutObjectOutcome upload_outcome(default_result);
73 std::vector<UploadDescription> uploaded_files;
74 for (
const auto& upload_description: upload_descriptions) {
76 std::lock_guard<std::recursive_mutex> lock(
mutex_);
81 auto file_path = upload_description.file_path;
82 auto object_key = upload_description.object_key;
84 AWS_LOGSTREAM_INFO(__func__,
"Uploading file " << file_path <<
" to " << object_key);
85 upload_outcome =
s3_facade_->PutObject(file_path, bucket, object_key);
86 if (!upload_outcome.IsSuccess()) {
89 completed_uploads.push_back(upload_description);
90 feedback_callback(completed_uploads);
93 std::lock_guard<std::recursive_mutex> lock(
mutex_);
96 return upload_outcome;
101 std::lock_guard<std::recursive_mutex> lock(
mutex_);
virtual bool IsAvailable() const
S3UploadManagerState manager_status_
virtual Model::PutObjectOutcome UploadFiles(const std::vector< UploadDescription > &upload_descriptions, const std::string &bucket, const boost::function< void(const std::vector< UploadDescription > &)> &feedback_callback)
virtual void CancelUpload()
std::unique_ptr< S3Facade > s3_facade_
S3UploadManager(const bool enable_encryption)
std::recursive_mutex mutex_