#include "c:\harbour\include\hbcurl2.ch"
function Main()
curl_global_init()
? FtpUploadFile( "sftp://000.000.000.000/files/prueba.txt", hb_GetEnv( "c:\prg" ) + "\prueba2.txt" )
curl_global_cleanup()
return nil
function FtpUploadFile( cUrlFileName, cFileName )
local hCurl, uValue, nResult
if ! empty( hCurl := curl_easy_init() )
curl_easy_setopt( hCurl, HB_CURLOPT_PROTOCOLS, HB_CURLPROTO_SFTP )
curl_easy_setopt( hCurl, HB_CURLOPT_URL, cUrlFileName )
curl_easy_setopt( hCurl, HB_CURLOPT_DL_BUFF_SETUP )
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 ) )
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. )
if ( nResult := curl_easy_perform( hCurl ) ) == 0
curl_easy_dl_buff_get( hCurl )
else
? "error code:" + Str( nResult )
endif
endif
return nResult == HB_CURLE_OK
#include "c:\harbour\include\hbcurl2.ch"
function Main()
curl_global_init()
? FtpUploadFile( "sftp://000.000.000.000/files/prueba.txt", hb_GetEnv( "c:\prg" ) + "\prueba2.txt" )
curl_global_cleanup()
return nil
function FtpUploadFile( cUrlFileName, cFileName )
local hCurl, uValue, nResult
local cResult := ""
if ! empty( hCurl := curl_easy_init() )
curl_easy_setopt( hCurl, HB_CURLOPT_PROTOCOLS, HB_CURLPROTO_SFTP )
curl_easy_setopt( hCurl, HB_CURLOPT_URL, cUrlFileName )
curl_easy_setopt( hCurl, HB_CURLOPT_DL_BUFF_SETUP )
//curl_easy_setopt( hCurl, HB_CURLOPT_UPLOAD ) // Es un download, no?
//curl_easy_setopt( hCurl, HB_CURLOPT_UL_FILE_SETUP, cFileName )
//curl_easy_setopt( hCurl, HB_CURLOPT_INFILESIZE, hb_vfSize( cFileName ) ) // Qué valor devuelve hb_vfSize( cFileName ) ?
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_TCP_KEEPALIVE, 1 )
curl_easy_setopt( hCurl, HB_CURLOPT_SSL_VERIFYHOST, 0 )
curl_easy_setopt( hCurl, HB_CURLOPT_SSL_VERIFYPEER, 0 )
curl_easy_setopt( hCurl, HB_CURLOPT_VERBOSE, 1 )
curl_easy_setopt( hCurl, HB_CURLOPT_USE_SSL, 0 )
if ( nResult := curl_easy_perform( hCurl ) ) == 0
cResult := curl_easy_dl_buff_get( hCurl )
? cResult
else
? "error code:" + Str( nResult )
endif
endif
return nResult == HB_CURLE_OK
#include "c:\harbour\include\hbcurl2.ch"
function Main()
curl_global_init()
? FtpUploadFile( "sftp://000.000.000.000/files/PRUEBAS/prueba.txt", "c:\prueba\prueba.txt" )
//? FtpDonwLoadFile( "sftp://000.000.000.000/files/PRUEBAS/prueba.txt", "c:\prueba\prueba.txt" )
curl_global_cleanup()
return nil
function FtpUploadFile( cUrlFileName, cFileName )
local hCurl, uValue, nResult
local cResult := ""
if ! empty( hCurl := curl_easy_init() )
curl_easy_setopt( hCurl, HB_CURLOPT_PROTOCOLS, HB_CURLPROTO_SFTP)
curl_easy_setopt( hCurl, HB_CURLOPT_URL, cUrlFileName )
curl_easy_setopt( hCurl, HB_CURLOPT_DL_BUFF_SETUP )
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 ) )
curl_easy_setopt( hCurl, HB_CURLOPT_USERPWD, "USUARIO:CONTRASEÑA" )
//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_TCP_KEEPALIVE, 1 )
curl_easy_setopt( hCurl, HB_CURLOPT_SSL_VERIFYHOST, 0 )
curl_easy_setopt( hCurl, HB_CURLOPT_SSL_VERIFYPEER, 0 )
curl_easy_setopt( hCurl, HB_CURLOPT_VERBOSE, 1 )
curl_easy_setopt( hCurl, HB_CURLOPT_USE_SSL, 0 )
if ( nResult := curl_easy_perform( hCurl ) ) == 0
cResult := curl_easy_dl_buff_get( hCurl )
//? cResult
else
? "error code:" + Str( nResult )
endif
endif
return nResult == HB_CURLE_OK
function FtpDoNwLoadFile( cUrlFileName, cFileName )
local hCurl, uValue, nResult
local cResult := ""
if ! empty( hCurl := curl_easy_init() )
curl_easy_setopt( hCurl, HB_CURLOPT_PROTOCOLS, HB_CURLPROTO_SFTP )
curl_easy_setopt( hCurl, HB_CURLOPT_URL, cUrlFileName )
curl_easy_setopt( hCurl, HB_CURLOPT_DL_BUFF_SETUP )
curl_easy_setopt( hCurl, HB_CURLOPT_USERPWD, "USUARIO:CONTRASEÑA" )
curl_easy_setopt( hCurl, HB_CURLOPT_UL_FILE_SETUP, cFileName )
curl_easy_setopt( hCurl, HB_CURLOPT_INFILESIZE, hb_vfSize( cFileName ) ) // Qué valor devuelve hb_vfSize( cFileName ) ?
curl_easy_setopt( hCurl, HB_CURLOPT_DOWNLOAD )
//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_TCP_KEEPALIVE, 1 )
curl_easy_setopt( hCurl, HB_CURLOPT_SSL_VERIFYHOST, 0 )
curl_easy_setopt( hCurl, HB_CURLOPT_SSL_VERIFYPEER, 0 )
curl_easy_setopt( hCurl, HB_CURLOPT_VERBOSE, 1 )
curl_easy_setopt( hCurl, HB_CURLOPT_USE_SSL, 0 )
if ( nResult := curl_easy_perform( hCurl ) ) == 0
cResult := curl_easy_dl_buff_get( hCurl )
? cResult
else
? "error code:" + Str( nResult )
endif
endif
return nResult == HB_CURLE_OK
Return to FiveWin para Harbour/xHarbour
Users browsing this forum: No registered users and 78 guests