remove this lines for only return list of files
- Code: Select all Expand view RUN
curl_easy_setopt( hCurl, HB_CURLOPT_UPLOAD )
curl_easy_setopt( hCurl, HB_CURLOPT_UL_FILE_SETUP, cFileName )
curl_easy_setopt( hCurl, HB_CURLOPT_INFILESIZE, hb_vfSize( cFileName ) )
Add
- Code: Select all Expand view RUN
curl_easy_setopt( hCurl, HB_CURLOPT_DIRLISTONLY, 1 )
and for SFTP, it's neccesary
- Code: Select all Expand view RUN
curl_easy_setopt( hCurl, HB_CURLOPT_PROTOCOLS, HB_CURLPROTO_SFTP )
and, this is important also
- Code: Select all Expand view RUN
curl_easy_setopt( hCurl, HB_CURLOPT_USE_SSL, 0 )
Full sample for directory files and conexion to SFTP
- Code: Select all Expand view RUN
curl_global_init()
if ! empty( hCurl := curl_easy_init() )
curl_easy_setopt( hCurl, HB_CURLOPT_PORT, cPort ) // default 22
curl_easy_setopt( hCurl, HB_CURLOPT_URL, cUrl )
curl_easy_setopt( hCurl, HB_CURLOPT_DL_BUFF_SETUP )
curl_easy_setopt( hCurl, HB_CURLOPT_USERPWD, "username:password" )
curl_easy_setopt( hCurl, HB_CURLOPT_FAILONERROR, .T. )
curl_easy_setopt( hCurl, HB_CURLOPT_FILETIME, .T. )
curl_easy_setopt( hCurl, HB_CURLOPT_NOPROGRESS, 0 )
curl_easy_setopt( hCurl, HB_CURLOPT_VERBOSE, .F. )
curl_easy_setopt( hCurl, HB_CURLOPT_DIRLISTONLY, 1 )
curl_easy_setopt( hCurl, HB_CURLOPT_USE_SSL, 0 )
curl_easy_setopt( hCurl, HB_CURLOPT_PROTOCOLS, HB_CURLPROTO_SFTP )
if ( nResult := curl_easy_perform( hCurl ) ) == 0
curl_easy_dl_buff_get( hCurl )
else
? "error code:" + Str( nResult )
endif
endif
curl_global_cleanup()
return nResult == HB_CURLE_OK