userver: userver/s3api/models/multipart_upload/requests.hpp Source File
Loading...
Searching...
No Matches
requests.hpp
1#pragma once
2
3#include <optional>
4#include <string>
5#include <vector>
6
7USERVER_NAMESPACE_BEGIN
8
9namespace s3api {
10
11struct Request;
12
13namespace multipart_upload {
14
15/// For some unclear reasons almost all fields in S3 API are optional
16/// including even those fields which are clearly stated to be required
17/// in S3 documentation.
18/// There are some unconvincing explanations for this at
19/// https://github.com/boto/botocore/issues/1069#issuecomment-259255047, but that's it!
20/// This implementation of the API in this library is a bit stricter than it is in S3 API
21/// specifciation, intentionally making some `optional` fields to be `required non-empty`.
22
23/// CreateMultipartUpload action request
24/// @see
25/// https://docs.aws.amazon.com/AmazonS3/latest/API/API_CreateMultipartUpload.html#API_CreateMultipartUpload_RequestSyntax
26/// NOTE:
27/// - `key` is expected to be URL encoded
29 std::string key;
30 std::optional<std::string> content_type;
31 std::optional<std::string> content_encoding;
32 std::optional<std::string> content_disposition;
33 std::optional<std::string> content_language;
34};
35
36/// CompleteMultipartUpload action request
37/// @see
38/// https://docs.aws.amazon.com/AmazonS3/latest/API/API_CreateMultipartUpload.html#API_CreateMultipartUpload_RequestSyntax
39/// NOTE:
40/// - For each part in the list of completed parts, you must provide the
41/// PartNumber value and the ETag value that are returned after that part was uploaded.
42/// All parts must be placed in ascending order by their PartNumber.
43/// @see https://docs.aws.amazon.com/AmazonS3/latest/API/API_CompleteMultipartUpload.html
44/// - `key` is expected to be URL encoded;
46 /// @see https://docs.aws.amazon.com/AmazonS3/latest/API/API_CompletedPart.html
47 // It may also contain optional Checksum* attributes.
48 // The specification states that all attributes are optional, however
49 // CompleteMultipartUpload action specification explicitly requires ETag and PartNumber.
51 unsigned part_number;
52 std::string etag;
53 };
54
55 std::string key;
56 std::string upload_id;
57 std::vector<CompletedPart> completed_parts;
58};
59
60/// AbortMultipartUpload action request
61/// @see
62/// https://docs.aws.amazon.com/AmazonS3/latest/API/API_AbortMultipartUpload.html#API_AbortMultipartUpload_RequestSyntax
63/// NOTE:
64/// - `key` is expected to be URL encoded
66 std::string key;
67 std::string upload_id;
68};
69
70/// UploadPart action request
71/// @see
72/// https://docs.aws.amazon.com/AmazonS3/latest/API/API_UploadPart.html#API_UploadPart_RequestSyntax
74 std::string key;
75 std::string upload_id;
76 unsigned part_number{0};
77 std::string data;
78};
79
80/// ListParts action request
81/// @see
82/// https://docs.aws.amazon.com/AmazonS3/latest/API/API_ListParts.html#API_ListParts_RequestSyntax
83/// NOTE:
84/// - The ListParts request returns a maximum of 1,000 uploaded parts.
85/// The limit of 1,000 parts is also the default value.
86/// - `key` is expected to be URL encoded
88 std::string key;
89 std::string upload_id;
90 unsigned max_parts{1000u};
91 std::optional<unsigned> part_number_marker;
92};
93
94/// ListMultipartUploads action request
95/// @see
96/// https://docs.aws.amazon.com/AmazonS3/latest/API/API_ListMultipartUploads.html#API_ListMultipartUploads_RequestSyntax
98 enum class EncodingType { kNone, kUrl };
99
100 EncodingType encoding_type{EncodingType::kNone};
101 unsigned max_uploads{1000u};
102 std::optional<std::string> delimiter;
103 std::optional<std::string> key_marker;
104 std::optional<std::string> prefix;
105 std::optional<std::string> upload_id_marker;
106};
107
108} // namespace multipart_upload
109} // namespace s3api
110
111USERVER_NAMESPACE_END