Debian Codegraph @

src/fileops/S3IO.hpp

raw
1 /*
2 * This File is part of Davix, The IO library for HTTP based protocols
3 * Copyright (C) CERN 2018
4 * Author: Georgios Bitzes <[email protected]>
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 *
20 */
21
22 #ifndef S3_IO_HPP
23 #define S3_IO_HPP
24
25 #include <fileops/httpiochain.hpp>
26
27 namespace Davix{
28
29 struct DynafedUris {
30 std::vector<std::string> chunks;
31 std::string post;
32 };
33
34 class S3IO : public HttpIOChain {
35 public:
36 S3IO();
37 ~S3IO();
38
39 // write from content provider
40 virtual dav_ssize_t writeFromProvider(IOChainContext & iocontext, ContentProvider &provider);
41
42 // Returns uploadId
43 virtual std::string initiateMultipart(IOChainContext & iocontext) override;
44
45 // Given the upload id and part#, write the given buffer and add the
46 // object id to the etags vector.
47 virtual bool writeFromBuffer(IOChainContext& iocontext, const char* buff,
48 dav_size_t size, const std::string& uploadId,
49 std::vector<std::string>& etags, int partNumber)
50 override;
51
52 // Given upload id and last chunk, commit chunks
53 virtual bool commitChunks(IOChainContext& iocontext,
54 const std::string& uploadId,
55 const std::vector<std::string>& etags) override;
56
57 void performUgrS3MultiPart(IOChainContext & iocontext, const std::string &posturl, const std::string &pluginId, ContentProvider &provider, DavixError **err);
58
59 private:
60
61 // Returns uploadId
62 std::string initiateMultipart(IOChainContext & iocontext, const Uri &url);
63
64 DynafedUris retrieveDynafedUris(IOChainContext & iocontext, const std::string &uploadId, const std::string &pluginId, size_t nchunks);
65
66 // Given the upload id, write the given chunk. Return object ETag,
67 // necessary to commit upload.
68 std::string writeChunk(IOChainContext & iocontext, const char* buff, dav_size_t size, const std::string &uploadId, int partNumber);
69 std::string writeChunk(IOChainContext & iocontext, const char* buff, dav_size_t size, const Uri &uri, int partNumber);
70
71
72 // Given upload id and last chunk, commit chunks
73 void commitChunks(IOChainContext & iocontext, const Uri &uri, const std::vector<std::string> &etags);
74 };
75
76 }
77
78 #endif