Downloads an export from the current system and saves as a file.
85 cout <<
"\n" <<
"Enter index of export to download [1-" << exports.
collectionSize <<
"] : ";
86 int exportIndex = Utility::ReadInt();
97 cout <<
"\n" <<
"Enter path to save export file: ";
98 string pathToSave = Utility::ReadString();
101 cout <<
"\n" <<
"Enter name to save export file: ";
102 string fileToSave = Utility::ReadString();
105 string fullPath = pathToSave +
"/" + fileToSave +
".zip";
109 mkdir(pathToSave.c_str(),0777);
111 _mkdir(pathToSave.c_str());
116 CURL *curl = curl_easy_init();
122 fp = fopen(fullPath.c_str(),
"wb");
124 fopen_s(&fp, fullPath.c_str(),
"wb");
129 *buff = *strerror(errno);
131 strerror_s(buff, 100, errno);
133 printf(
"Error opening file for writing: %s\n", buff);
138 struct curl_slist *headers =
nullptr;
140 string userNameHeader =
"X-Serenity-User: " + Utility::Encode(
username);
141 string passwordHeader =
"X-Serenity-Password: " + Utility::Encode(
password);
142 headers = curl_slist_append(headers, userNameHeader.c_str());
143 headers = curl_slist_append(headers, passwordHeader.c_str());
146 curl_easy_setopt(curl, CURLOPT_URL, vxExport->
dataUri);
147 curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION,
WriteData);
148 curl_easy_setopt(curl, CURLOPT_WRITEDATA, fp);
149 curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 0);
150 curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0);
151 curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
152 curl_easy_setopt(curl, CURLOPT_NOPROGRESS, 0);
153 curl_easy_setopt(curl, CURLOPT_PROGRESSFUNCTION,
ProgressFunc);
154 curl_easy_setopt(curl, CURLOPT_PROGRESSDATA, &actualFileSize);
157 cout <<
"\n" <<
"Exporting to " << fullPath <<
"\n\n";
158 curl_easy_perform(curl);
160 curl_easy_cleanup(curl);
static int ProgressFunc(void *ptr, double dltotal, double dlnow)
Callback method to get the download progress
std::string password
The password used to log in to the VideoXpert system.
static size_t WriteData(void *ptr, size_t size, size_t nmemb, FILE *stream)
Callback method for writing export data to file
std::string username
The user name used to log in to the VideoXpert system.
static void DisplayExportDetailsOnScreen(VxSdk::VxCollection< VxSdk::IVxExport ** > exportCollection)
Prints the given collection of exports to the screen.
static VxSdk::VxCollection< VxSdk::IVxExport ** > GetExports(VxSdk::IVxSystem *vxSystem)
Get a collection of exports from the given VideoExpert system.
static void ShowExportDetails(VxSdk::IVxExport *vxExport)
Print the details of given export.