31 #ifndef CPL_ALIBABA_OSS_INCLUDED_H
32 #define CPL_ALIBABA_OSS_INCLUDED_H
42 #include <curl/curl.h>
46 class VSIOSSHandleHelper final :
public IVSIS3LikeHandleHelper
50 std::string m_osURL{};
51 std::string m_osSecretAccessKey{};
52 std::string m_osAccessKeyId{};
53 std::string m_osEndpoint{};
54 std::string m_osBucket{};
55 std::string m_osObjectKey{};
56 bool m_bUseHTTPS =
false;
57 bool m_bUseVirtualHosting =
false;
59 void RebuildURL()
override;
61 static bool GetConfiguration(
const std::string &osPathForOption,
63 std::string &osSecretAccessKey,
64 std::string &osAccessKeyId);
68 VSIOSSHandleHelper(
const std::string &osSecretAccessKey,
69 const std::string &osAccessKeyId,
70 const std::string &osEndpoint,
71 const std::string &osBucket,
72 const std::string &osObjectKey,
bool bUseHTTPS,
73 bool bUseVirtualHosting);
74 ~VSIOSSHandleHelper();
76 static VSIOSSHandleHelper *
77 BuildFromURI(
const char *pszURI,
const char *pszFSPrefix,
78 bool bAllowNoObject,
CSLConstList papszOptions =
nullptr);
79 static std::string BuildURL(
const std::string &osEndpoint,
80 const std::string &osBucket,
81 const std::string &osObjectKey,
bool bUseHTTPS,
82 bool bUseVirtualHosting);
85 GetCurlHeaders(
const std::string &osVerb,
86 const struct curl_slist *psExistingHeaders,
87 const void *pabyDataContent =
nullptr,
88 size_t nBytesContent = 0)
const override;
90 bool CanRestartOnError(
const char *,
const char *pszHeaders,
91 bool bSetError)
override;
93 const std::string &GetURL()
const override
98 const std::string &GetBucket()
const
103 const std::string &GetObjectKey()
const
105 return m_osObjectKey;
108 const std::string &GetEndpoint()
const
113 bool GetVirtualHosting()
const
115 return m_bUseVirtualHosting;
118 std::string GetCopySourceHeader()
const override
120 return "x-oss-copy-source";
123 void SetEndpoint(
const std::string &osStr);
124 void SetVirtualHosting(
bool b);
129 class VSIOSSUpdateParams
132 std::string m_osEndpoint{};
134 explicit VSIOSSUpdateParams(
const VSIOSSHandleHelper *poHelper)
135 : m_osEndpoint(poHelper->GetEndpoint())
139 void UpdateHandlerHelper(VSIOSSHandleHelper *poHelper)
141 poHelper->SetEndpoint(m_osEndpoint);
144 static std::mutex gsMutex;
145 static std::map<std::string, VSIOSSUpdateParams> goMapBucketsToOSSParams;
148 VSIOSSUpdateParams() =
default;
150 static void UpdateMapFromHandle(VSIOSSHandleHelper *poHandleHelper);
151 static void UpdateHandleFromMap(VSIOSSHandleHelper *poHandleHelper);
152 static void ClearCache();
#define CPL_DISALLOW_COPY_ASSIGN(ClassName)
Helper to remove the copy and assignment constructors so that the compiler will not generate the defa...
Definition: cpl_port.h:1042
char ** CSLConstList
Type of a constant null-terminated list of nul terminated strings.
Definition: cpl_port.h:1183
Various convenience functions for working with strings and string lists.