I made app with visual studio 2015 and used libcurl.
but this shows error "Couldn't resolve host name"
CURL *curl;
CURLcode res;
std::string readBuffer;
// Your Dropbox access token
std::string accessToken = "****";
// File to upload
std::string filePath = "D://test.txt";
std::string fileName = "file.txt"; // Name of the file as it will appear in Dropbox
// Open the file
std::ifstream file(filePath, std::ios::binary | std::ios::ate);
if (!file.is_open()) {
std::cerr << "Failed to open file." << std::endl;
return 1;
}
// Get file size
std::size_t fileSize = file.tellg();
file.seekg(0, std::ios::beg);
// Read the file into a buffer
char* fileBuffer = new char[fileSize];
file.read(fileBuffer, fileSize);
file.close();
// Set up the API request
curl_global_init(CURL_GLOBAL_DEFAULT);
curl = curl_easy_init();
if (curl) {
struct curl_slist *headers = NULL;
headers = curl_slist_append(headers, ("Authorization: Bearer " + accessToken).c_str());
headers = curl_slist_append(headers, "Content-Type: application/octet-stream");
// Dropbox API specifics
std::string dropboxApiArg = "{\"path\":\"/" + fileName + "\",\"mode\":\"add\",\"autorename\":true,\"mute\":false}";
headers = curl_slist_append(headers, ("Dropbox-API-Arg: " + dropboxApiArg).c_str());
curl_easy_setopt(curl, CURLOPT_URL, url.c_str());
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, WriteCallback);
curl_easy_setopt(curl, CURLOPT_WRITEDATA, &readBuffer);
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, fileBuffer);
curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, fileSize);
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
res = curl_easy_perform(curl);
if (res != CURLE_OK) {
std::cerr << "cURL error: " << curl_easy_strerror(res) << std::endl;
}
else {
std::cout << "File uploaded successfully." << std::endl;
}
// Cleanup
curl_easy_cleanup(curl);
curl_slist_free_all(headers);
delete[] fileBuffer;
}
curl_global_cleanup();
return 0;
please help me