SDTS_AL
cpl_azure.h
1/**********************************************************************
2 * Project: CPL - Common Portability Library
3 * Purpose: Microsoft Azure Storage Blob routines
4 * Author: Even Rouault <even.rouault at spatialys.com>
5 *
6 **********************************************************************
7 * Copyright (c) 2017, Even Rouault <even.rouault at spatialys.com>
8 *
9 * Permission is hereby granted, free of charge, to any person obtaining a
10 * copy of this software and associated documentation files (the "Software"),
11 * to deal in the Software without restriction, including without limitation
12 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
13 * and/or sell copies of the Software, and to permit persons to whom the
14 * Software is furnished to do so, subject to the following conditions:
15 *
16 * The above copyright notice and this permission notice shall be included
17 * in all copies or substantial portions of the Software.
18 *
19 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
20 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
22 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
24 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
25 * DEALINGS IN THE SOFTWARE.
26 ****************************************************************************/
27
28#ifndef CPL_AZURE_INCLUDED_H
29#define CPL_AZURE_INCLUDED_H
30
31#ifndef DOXYGEN_SKIP
32
33#ifdef HAVE_CURL
34
35#include <curl/curl.h>
36#include "cpl_http.h"
37#include "cpl_aws.h"
38#include <map>
39
40class VSIAzureBlobHandleHelper final: public IVSIS3LikeHandleHelper
41{
42 CPLString m_osURL;
43 CPLString m_osEndpoint;
44 CPLString m_osBucket;
45 CPLString m_osObjectKey;
46 CPLString m_osStorageAccount;
47 CPLString m_osStorageKey;
48 bool m_bUseHTTPS;
49
50 static bool GetConfiguration(CSLConstList papszOptions,
51 bool& bUseHTTPS,
52 CPLString& osEndpoint,
53 CPLString& osStorageAccount,
54 CPLString& osStorageKey);
55
56 static CPLString BuildURL(const CPLString& osEndpoint,
57 const CPLString& osStorageAccount,
58 const CPLString& osBucket,
59 const CPLString& osObjectKey,
60 bool bUseHTTPS);
61
62 void RebuildURL() override;
63
64 public:
65 VSIAzureBlobHandleHelper(const CPLString& osEndpoint,
66 const CPLString& osBucket,
67 const CPLString& osObjectKey,
68 const CPLString& osStorageAccount,
69 const CPLString& osStorageKey,
70 bool bUseHTTPS);
71 ~VSIAzureBlobHandleHelper();
72
73 static VSIAzureBlobHandleHelper* BuildFromURI(const char* pszURI,
74 const char* pszFSPrefix,
75 CSLConstList papszOptions = nullptr);
76
77 struct curl_slist* GetCurlHeaders(const CPLString& osVerbosVerb,
78 const struct curl_slist* psExistingHeaders,
79 const void *pabyDataContent = nullptr,
80 size_t nBytesContent = 0) const override;
81
82 const CPLString& GetURL() const override { return m_osURL; }
83
84 CPLString GetSignedURL(CSLConstList papszOptions);
85};
86
87
88#endif /* HAVE_CURL */
89
90#endif /* #ifndef DOXYGEN_SKIP */
91
92#endif /* CPL_AZURE_INCLUDED_H */
char ** CSLConstList
Definition: cpl_port.h:1184