• 1000 ниже ...:
const string url = _baseUrl + "/myEndpoint";
const string filepath = "MyFilepath/to/an/existing/file.zip";
const string name = "DatasetName";
const string id = "1234-5678";
const string meta = "Just a short comment.";
curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, "POST");
curl_easy_setopt(curl, CURLOPT_URL, url.c_str());
curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);
curl_easy_setopt(curl, CURLOPT_DEFAULT_PROTOCOL, "https");
struct curl_slist *headers = NULL;
headers = curl_slist_append(headers, ("Authorization: Bearer MyFancyBearerToken").c_str());
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
curl_mime *mime;
curl_mimepart *part;
mime = curl_mime_init(curl);
part = curl_mime_addpart(mime);
curl_mime_name(part, "file");
curl_mime_filedata(part, filepath.c_str());
part = curl_mime_addpart(mime);
curl_mime_name(part, "name");
curl_mime_data(part, name.c_str(), CURL_ZERO_TERMINATED);
part = curl_mime_addpart(mime);
curl_mime_name(part, "id");
curl_mime_data(part, id.c_str(), CURL_ZERO_TERMINATED);
if (!meta.empty())
{
part = curl_mime_addpart(mime);
curl_mime_name(part, "meta");
curl_mime_data(part, meta.c_str(), CURL_ZERO_TERMINATED);
}
curl_easy_setopt(curl, CURLOPT_MIMEPOST, mime);
res = curl_easy_perform(curl);
curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &httpCode);
curl_mime_free(mime);
curl_easy_cleanup(curl);
curl = nullptr;
Я приветствую любые подсказки, почему длина не может быть определена / отправлена.