'
' Download a binary file example over FTP using CURL - PvE december 2010
'

' Include the CURL context
INCLUDE "curl.bac"

CONST filename$ = "file.tar.gz"

' File where we store the download
OPEN filename$ FOR WRITING AS download

' Create the handle
easyhandle = curl_easy_init()

' Set the options
curl_easy_setopt(easyhandle, CURLOPT_URL, CONCAT$("ftp://ftp.server.com/pub/", filename$))
curl_easy_setopt(easyhandle, CURLOPT_WRITEDATA, download)
curl_easy_setopt(easyhandle, CURLOPT_USERPWD, "user:passwd")

' Perform the GET
success = curl_easy_perform(easyhandle)

' Cleanup
curl_easy_cleanup(easyhandle)

' Close filehandle
CLOSE FILE download

' Print Curl version
PRINT NL$, "Downloaded '", filename$, "' using CURL version: ", curl_version$(), NL$