GDAL
cpl_alibaba_oss.h
1 /**********************************************************************
2  * $Id: cpl_alibaba_oss.h 40377 2017-10-09 22:51:05Z rouault $
3  *
4  * Name: cpl_alibaba_oss.h
5  * Project: CPL - Common Portability Library
6  * Purpose: Alibaba Cloud Object Storage Service
7  * Author: Even Rouault <even.rouault at spatialys.com>
8  *
9  **********************************************************************
10  * Copyright (c) 2017, Even Rouault <even.rouault at spatialys.com>
11  *
12  * Permission is hereby granted, free of charge, to any person obtaining a
13  * copy of this software and associated documentation files (the "Software"),
14  * to deal in the Software without restriction, including without limitation
15  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
16  * and/or sell copies of the Software, and to permit persons to whom the
17  * Software is furnished to do so, subject to the following conditions:
18  *
19  * The above copyright notice and this permission notice shall be included
20  * in all copies or substantial portions of the Software.
21  *
22  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
23  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
24  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
25  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
26  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
27  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
28  * DEALINGS IN THE SOFTWARE.
29  ****************************************************************************/
30 
31 #ifndef CPL_ALIBABA_OSS_INCLUDED_H
32 #define CPL_ALIBABA_OSS_INCLUDED_H
33 
34 #ifndef DOXYGEN_SKIP
35 
36 #include <cstddef>
37 
38 #include "cpl_string.h"
39 
40 #ifdef HAVE_CURL
41 
42 #include <curl/curl.h>
43 #include <map>
44 #include "cpl_aws.h"
45 
46 class VSIOSSHandleHelper: public IVSIS3LikeHandleHelper
47 {
48  CPLString m_osURL;
49  CPLString m_osSecretAccessKey;
50  CPLString m_osAccessKeyId;
51  CPLString m_osEndpoint;
52  CPLString m_osBucket;
53  CPLString m_osObjectKey;
54  bool m_bUseHTTPS;
55  bool m_bUseVirtualHosting;
56 
57  virtual void RebuildURL() CPL_OVERRIDE;
58 
59  protected:
60 
61  public:
62  VSIOSSHandleHelper(const CPLString& osSecretAccessKey,
63  const CPLString& osAccessKeyId,
64  const CPLString& osEndpoint,
65  const CPLString& osBucket,
66  const CPLString& osObjectKey,
67  bool bUseHTTPS, bool bUseVirtualHosting);
68  ~VSIOSSHandleHelper();
69 
70  static VSIOSSHandleHelper* BuildFromURI(const char* pszURI,
71  const char* pszFSPrefix,
72  bool bAllowNoObject);
73  static CPLString BuildURL(const CPLString& osEndpoint,
74  const CPLString& osBucket,
75  const CPLString& osObjectKey,
76  bool bUseHTTPS, bool bUseVirtualHosting);
77 
78  struct curl_slist* GetCurlHeaders(const CPLString& osVerb,
79  const struct curl_slist* psExistingHeaders,
80  const void *pabyDataContent = NULL,
81  size_t nBytesContent = 0) const CPL_OVERRIDE;
82 
83  bool CanRestartOnError(const char*, bool bSetError = false) CPL_OVERRIDE;
84 
85  const CPLString& GetURL() const CPL_OVERRIDE { return m_osURL; }
86  const CPLString& GetBucket() const { return m_osBucket; }
87  const CPLString& GetObjectKey() const { return m_osObjectKey; }
88  const CPLString& GetEndpoint()const { return m_osEndpoint; }
89  bool GetVirtualHosting() const { return m_bUseVirtualHosting; }
90  void SetEndpoint(const CPLString &osStr);
91  void SetVirtualHosting(bool b);
92 
93  static bool GetConfiguration(CPLString& osSecretAccessKey,
94  CPLString& osAccessKeyId);
95 };
96 
97 class VSIOSSUpdateParams
98 {
99  public:
100  CPLString m_osEndpoint;
101 
102  VSIOSSUpdateParams() {}
103 
104  explicit VSIOSSUpdateParams(const VSIOSSHandleHelper* poHelper) :
105  m_osEndpoint(poHelper->GetEndpoint()) {}
106 
107  void UpdateHandlerHelper(VSIOSSHandleHelper* poHelper) {
108  poHelper->SetEndpoint(m_osEndpoint);
109  }
110 };
111 
112 #endif /* HAVE_CURL */
113 
114 #endif /* #ifndef DOXYGEN_SKIP */
115 
116 #endif /* CPL_ALIBABA_OSS_INCLUDED_H */
#define CPL_OVERRIDE
To be used in public headers only.
Definition: cpl_port.h:1055
Convenient string class based on std::string.
Definition: cpl_string.h:338
Various convenience functions for working with strings and string lists.

Generated for GDAL by doxygen 1.8.8.