/root/doris/be/src/util/s3_uri.h
Line | Count | Source (jump to first uncovered line) |
1 | | // Licensed to the Apache Software Foundation (ASF) under one |
2 | | // or more contributor license agreements. See the NOTICE file |
3 | | // distributed with this work for additional information |
4 | | // regarding copyright ownership. The ASF licenses this file |
5 | | // to you under the Apache License, Version 2.0 (the |
6 | | // "License"); you may not use this file except in compliance |
7 | | // with the License. You may obtain a copy of the License at |
8 | | // |
9 | | // http://www.apache.org/licenses/LICENSE-2.0 |
10 | | // |
11 | | // Unless required by applicable law or agreed to in writing, |
12 | | // software distributed under the License is distributed on an |
13 | | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
14 | | // KIND, either express or implied. See the License for the |
15 | | // specific language governing permissions and limitations |
16 | | // under the License. |
17 | | |
18 | | #pragma once |
19 | | |
20 | | #include <string> |
21 | | |
22 | | #include "common/status.h" |
23 | | #include "util/string_util.h" |
24 | | |
25 | | namespace doris { |
26 | | |
27 | | // S3URI can handle following input: |
28 | | // 1. s3://bucket_name/path/to/file.txt |
29 | | // bucket: bucket_num |
30 | | // key: path/to/file.txt |
31 | | // 2. path/to/file.txt |
32 | | // bucket: "" |
33 | | // key: path/to/file.txt |
34 | | class S3URI { |
35 | | public: |
36 | 12 | S3URI(const std::string& location) : _location(location) {} |
37 | | Status parse(); |
38 | 6 | const std::string& get_bucket() const { return _bucket; } |
39 | 7 | const std::string& get_key() const { return _key; } |
40 | 0 | const std::string& get_location() const { return _location; } |
41 | | std::string to_string() const; |
42 | | |
43 | | private: |
44 | | static const std::string _SCHEME_S3; |
45 | | static const std::string _SCHEME_HTTP; |
46 | | static const std::string _SCHEME_HTTPS; |
47 | | static const std::string _SCHEME_DELIM; |
48 | | static const std::string _PATH_DELIM; |
49 | | static const std::string _QUERY_DELIM; |
50 | | static const std::string _FRAGMENT_DELIM; |
51 | | static const StringCaseSet _VALID_SCHEMES; |
52 | | |
53 | | std::string _location; |
54 | | std::string _bucket; |
55 | | std::string _key; |
56 | | }; |
57 | | } // end namespace doris |