AWS SDK for C++  0.14.3
AWS SDK for C++
DownloadFileRequest.h
Go to the documentation of this file.
1 
2 /*
3  * Copyright 2010-2015 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License").
6  * You may not use this file except in compliance with the License.
7  * A copy of the License is located at
8  *
9  * http://aws.amazon.com/apache2.0
10  *
11  * or in the "license" file accompanying this file. This file is distributed
12  * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13  * express or implied. See the License for the specific language governing
14  * permissions and limitations under the License.
15  */
16 
17 #pragma once
18 
20 
22 #include <aws/s3/S3Client.h>
23 
24 #include <fstream>
25 
26 namespace Aws
27 {
28 namespace S3
29 {
30  class S3Client;
31 } // namespace S3
32 
33 namespace Http
34 {
35  class HttpRequest;
36  class HttpResponse;
37 }
38 
39 namespace Transfer
40 {
41 
42 class TransferClient;
43 
44 class AWS_TRANSFER_API DownloadFileRequest : public S3FileRequest, public std::enable_shared_from_this<DownloadFileRequest>
45 {
46 public:
47  DownloadFileRequest(const Aws::String& fileName, const Aws::String& bucketName, const Aws::String& keyName, const std::shared_ptr<Aws::S3::S3Client>& s3Client);
49 
50  bool DoSingleObjectDownload();
51 
52  bool IsReady() const override;
53 
54  void OnDataReceived(const Aws::Http::HttpRequest*, Aws::Http::HttpResponse*, long long);
55 
56  uint32_t GetRetries() const { return m_retries; }
57 
58  friend class TransferClient;
59 
60 private:
61 
62  bool HandleGetObjectOutcome(const Aws::S3::Model::GetObjectRequest& request,
63  const Aws::S3::Model::GetObjectOutcome& outcome);
64 
65  bool HandleListObjectsOutcome(const Aws::S3::Model::ListObjectsRequest& request,
66  const Aws::S3::Model::ListObjectsOutcome& outcome);
67 
68  void GetContents();
69 
70  bool DoRetry();
71 
72  virtual bool DoCancelAction() override;
73 
74  mutable std::mutex m_fileRequestMutex;
75 
76  uint32_t m_retries;
77  bool m_gotContents;
78 };
79 
80 } // namespace Transfer
81 } // namespace Aws
#define AWS_TRANSFER_API
std::basic_string< char, std::char_traits< char >, Aws::Allocator< char > > String
Definition: AWSString.h:97
JSON (JavaScript Object Notation).