| 142 | } |
| 143 | |
| 144 | int64_t S3WrapperBase::writeFetchedBody(Aws::IOStream& source, const int64_t data_size, const std::shared_ptr<io::BaseStream>& output) { |
| 145 | static const uint64_t BUFFER_SIZE = 4096; |
| 146 | std::vector<uint8_t> buffer; |
| 147 | buffer.reserve(BUFFER_SIZE); |
| 148 | |
| 149 | int64_t write_size = 0; |
| 150 | while (write_size < data_size) { |
| 151 | auto next_write_size = data_size - write_size < BUFFER_SIZE ? data_size - write_size : BUFFER_SIZE; |
| 152 | if (!source.read(reinterpret_cast<char*>(buffer.data()), next_write_size)) { |
| 153 | return -1; |
| 154 | } |
| 155 | auto ret = output->write(buffer.data(), next_write_size); |
| 156 | if (ret < 0) { |
| 157 | return ret; |
| 158 | } |
| 159 | write_size += next_write_size; |
| 160 | } |
| 161 | return write_size; |
| 162 | } |
| 163 | |
| 164 | minifi::utils::optional<GetObjectResult> S3WrapperBase::getObject(const GetObjectRequestParameters& get_object_params, const std::shared_ptr<io::BaseStream>& out_body) { |
| 165 | Aws::S3::Model::GetObjectRequest request; |