--!movie
--!encoding=utf-8
global $
----------------------------------------
-- Upload file with ftp (synchronous/blocking mode)
----------------------------------------
on startMovie
_player.debugPlaybackEnabled = 1
-- libs
$.import("curl")
-- config
tLocalFile = $.PATH & "ftp_upload.lsw" -- this script file
tRemoteFile = "ftp://domain.com/test/ftp_upload.lsw"
tUsername = "john.doe"
tPassword = "********"
-- get a CURL handle (xtra instance)
ch = $.curl.init()
-- specify options
ch.setOption($.curl.CURLOPT.URL, tRemoteFile)
ch.setOption($.curl.CURLOPT.USERNAME, tUsername)
ch.setOption($.curl.CURLOPT.PASSWORD, tPassword)
ch.setOption($.curl.CURLOPT.UPLOAD, 1)
-- upload source
ch.setSourceFile(tLocalFile)
-- returnMode: 0=return error code (=default), 1=return data
res = ch.exec(0) -- we don't want to return data
put "UPLOAD FINISHED!"
put "ERROR:" && curl_error(res)
--put "SPEED_UPLOAD:" && ch.getInfo($.curl.CURLINFO.SPEED_UPLOAD)
--put "TOTAL_TIME:" && ch.getInfo($.curl.CURLINFO.TOTAL_TIME)
end