1 /*
2  * Copyright (c) 2022 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef UPLOAD_CONFIG
17 #define UPLOAD_CONFIG
18 
19 #include <map>
20 #include <string>
21 #include <vector>
22 
23 #include "curl/curl.h"
24 
25 namespace OHOS::Request::Upload {
26 struct File {
27     std::string filename;
28     std::string name;
29     std::string uri;
30     std::string type;
31 };
32 
33 struct RequestData {
34     std::string name;
35     std::string value;
36 };
37 
38 struct UploadResponse {
39     int32_t code;
40     std::string data;
41     std::string headers;
42 };
43 
44 struct UploadConfig {
45     std::string url;
46     std::map<std::string, std::string> header;
47     std::string method;
48     std::vector<File> files;
49     std::vector<RequestData> data;
50     std::function<void(UploadResponse &data)> fsuccess;
51     std::function<void(std::string &data, int32_t &code)> ffail;
52     std::function<void()> fcomplete;
53     std::string protocolVersion;
54 };
55 class CUrlAdp;
56 struct FileData {
57     FILE *fp;
58     std::string filename;
59     std::string name;
60     std::string type;
61     std::shared_ptr<CUrlAdp> adp;
62     int64_t upsize;
63     int64_t totalsize;
64     uint32_t fileIndex;
65     struct curl_slist *list;
66     std::vector<std::string> responseHead;
67     int32_t headSendFlag;
68     int32_t httpCode;
69     uint32_t result;
70 };
71 } // namespace OHOS::Request::Upload
72 #endif