Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <curl/curl.h>
- size_t WriteCallback(void* contents, size_t size, size_t nmemb, void* userp)
- {
- size_t totalSize = size * nmemb;
- reinterpret_cast<std::string*>(userp)->append(reinterpret_cast<char*>(contents), totalSize);
- return totalSize;
- }
- int main()
- {
- CURL *curl = curl_easy_init();
- if(curl) {
- std::string readBuffer;
- curl_easy_setopt(curl, CURLOPT_URL, "https://192.168.100.100/application-files/JTDemo.wef.gz");
- curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, WriteCallback);
- curl_easy_setopt(curl, CURLOPT_WRITEDATA, &readBuffer);
- curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0L); // Skip SSL verification, not recommended in production
- curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 0L); // Skip SSL verification, not recommended in production
- CURLcode res = curl_easy_perform(curl);
- if(res != CURLE_OK) {
- fprintf(stderr, "curl_easy_perform() failed: %s\n", curl_easy_strerror(res));
- }
- else {
- std::ofstream outFile("JTDemo.wef.gz", std::ios::binary);
- outFile << readBuffer;
- }
- curl_easy_cleanup(curl);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement