s3_upload_manager.h
Go to the documentation of this file.
1 /*
2  * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License").
5  * You may not use this file except in compliance with the License.
6  * A copy of the License is located at
7  *
8  * http://aws.amazon.com/apache2.0
9  *
10  * or in the "license" file accompanying this file. This file is distributed
11  * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
12  * express or implied. See the License for the specific language governing
13  * permissions and limitations under the License.
14  */
15 #pragma once
16 
17 #include <memory>
18 #include <string>
19 #include <boost/function.hpp>
20 
21 #include <aws/s3/S3Client.h>
22 
23 #include <s3_common/s3_facade.h>
24 
25 namespace Aws
26 {
27 namespace S3
28 {
29 
31 {
32  // The upload manager isn't uploading any files
33  AVAILABLE = 0,
34  // The upload manager is uploading files
36  // The upload manager is canceling a request to upload files
38 };
39 
41 {
42  std::string file_path;
43  std::string object_key;
44  bool operator==(const UploadDescription& rhs) const
45  {
46  return file_path == rhs.file_path && object_key == rhs.object_key;
47  }
48 };
49 
50 // Manages uploading a list of files to Amazon S3
52 {
53 public:
59  explicit S3UploadManager(const bool enable_encryption);
60 
67  explicit S3UploadManager(const bool enable_encryption, const Aws::Client::ClientConfiguration &config);
68 
74  explicit S3UploadManager(std::unique_ptr<S3Facade> s3_facade);
75 
76  virtual ~S3UploadManager() = default;
77 
78  /* Cancel the current upload
79  */
80  virtual void CancelUpload();
81 
82  /* Upload a list of files to S3
83  * @param upload_descriptions a vector of files to upload to S3
84  * @param bucket the name of the s3 bucket to target. Must be in the same region as the client config
85  * @param feedback_callback called with the list of UploadDescriptions that have been finished
86  * @return An PutObjectOutcome
87  */
88  virtual Model::PutObjectOutcome UploadFiles(
89  const std::vector<UploadDescription> & upload_descriptions,
90  const std::string & bucket,
91  const boost::function<void (const std::vector<UploadDescription>&)>& feedback_callback);
92 
93  virtual bool IsAvailable() const;
94 
95 private:
96  // The current state of the upload manager
98  // Guards manager_status_
99  mutable std::recursive_mutex mutex_;
100  // Facade for interaction with S3 client
101  std::unique_ptr<S3Facade> s3_facade_;
102 };
103 
104 } // namespace S3
105 } // namespace Aws
S3UploadManagerState manager_status_
bool operator==(const UploadDescription &rhs) const
std::unique_ptr< S3Facade > s3_facade_
std::recursive_mutex mutex_


s3_common
Author(s): AWS RoboMaker
autogenerated on Tue Jun 1 2021 02:51:29