I need to upload directories to a FTP server on my application, and plan to use libcurl. I see there is no direct way to upload a directory with many files, which makes sense to me. I couldn't, however, find any mention on uploading many files.
If I get the list of files in the directory, I could upload them in a loop.
The option CURLOPT_FTP_CREATE_MISSING_DIRS
might help with sub-directories,
but if I'd like to know also if I'm missing the point here or this would have
any serious drawback.
The main question is: how can I keep the connection "open"? Reconnecting on each file would probably mean an extra unwanted overhead.
Ideally, I'd like to keep using the easy interface. But if another interface provides better support in this case, I'll use it.
CURLcode ret;
CURL *handle = curl_easy_init();
/* Connect to FTP server using *
* the given username and password */
for ({each file}) {
curl_easy_setopt(handle, ..., ...);
...
ret = curl_easy_perform(handle);
/* Analyse return code */
curl_easy_reset(handle);
}
/* Disconnect from server */
curl_easy_clenup(handle);