• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 <string>
20 #include <vector>
21 #include "curl/curl.h"
22 
23 namespace OHOS::Request::Upload {
24 struct File {
25     std::string filename;
26     std::string name;
27     std::string uri;
28     std::string type;
29 };
30 
31 struct RequestData {
32     std::string name;
33     std::string value;
34 };
35 
36 struct UploadResponse {
37     int32_t code;
38     std::string data;
39     std::string headers;
40 };
41 
42 struct UploadConfig {
43     std::string url;
44     std::vector<std::string> header;
45     std::string method;
46     std::vector<File> files;
47     std::vector<RequestData> data;
48     std::function<void(UploadResponse &data)> fsuccess;
49     std::function<void(std::string &data, int32_t &code)> ffail;
50     std::function<void()> fcomplete;
51     std::string protocolVersion;
52 };
53 class CUrlAdp;
54 struct FileData {
55     FILE *fp;
56     std::string filename;
57     std::string name;
58     std::string type;
59     std::shared_ptr<CUrlAdp> adp;
60     int64_t upsize;
61     int64_t totalsize;
62     uint32_t fileIndex;
63     struct curl_slist *list;
64     std::vector<std::string> responseHead;
65     int32_t headSendFlag;
66     int32_t httpCode;
67     uint32_t result;
68 };
69 } // end of OHOS::Request::Upload
70 #endif