FTP uploads with curl - monitoring progress - any ideas?
Ken Ray
kray at sonsothunder.com
Thu Mar 4 20:16:04 EST 2010
Thanks, Phil! Josh sent me his code as well so having both will let me get
this done!
Thanks again...
Ken
On 3/4/10 2:16 PM, "Phil Davis" <revdev at pdslabs.net> wrote:
> Hi Ken,
>
> If you open curl as a process, you can then read the status info one
> line at a time. Would that work?
>
> Here's one way (courtesy of Josh Mellicker, with some mods):
>
> -- a button script --
>
> local vCurlProcess
>
>
> on mouseUp
> put empty into fld "output"
> put formattedForCurl(fld "filename") into tFiles
>
> put ("curl -T" && tFiles && fld "server" && "-C -") into vCurlProcess
> open process vCurlProcess for read
> get the result
> if it = empty
> then send "getCurlReport" to me in 12 ticks
> else answer it
> end mouseUp
>
>
> on getCurlReport
> read from process vCurlProcess for 1 line
> put it after fld "output"
> if it = empty
> then closeCurl
> else send "getCurlReport" to me in 12 ticks
> end getCurlReport
>
>
> on closeCurl
> close process vCurlProcess
> answer "Done."
> end closeCurl
>
>
> function formattedForCurl pFileList
> -- handle single file selection
> if the number of lines in pFileList = 1 then return quote &
> pFileList & quote
>
> -- handle multi file selections
> replace CR with "," in pFileList
> put quote & "{" & pFileList & "}" & quote into tList
> return tList
> end formattedForCurl
>
>
> There you have it!
> Phil
>
>
>
> On 3/4/10 10:28 AM, Ken Ray wrote:
>> I have some large files (100MB +) that I need to FTP to a customer's server.
>> I have tried to use libURL to do the uploading, but I get odd results/random
>> timeouts/errant status messages when the file I'm uploading is over 40MB.
>> I've tried many different workarounds to this, but none have been
>> consistent/acceptable so for this project I'm seeing if I can use curl.
>>
>> The pain is that there doesn't seem to be a way to retrieve the progress of
>> an FTP upload so I can display a custom upload box. If I redirect it to
>> dev/null, I get control back after the upload starts, but I can't get any
>> progress data:
>>
>> curl -T filePath -u user:pass serverAdress> /dev/null 2>&1&
>>
>> If I redirect to stdin, it's blocking and I only get anything when the
>> upload is complete:
>>
>> curl -T filePath -u user:pass serverAdress> stdin
>>
>> I've also tried:
>>
>> curl -T filePath -u user:pass serverAdress> stdin&
>> curl -T filePath -u user:pass serverAdress> stdin 2>&1&
>>
>> Is there any way to make a non-blocking call to curl, but then to get back
>> the progress text that would normally be displayed in the Terminal?
>>
>> Any help would be appreciated...
>>
>> Ken Ray
>> Sons of Thunder Software, Inc.
>> Email: kray at sonsothunder.com
>> Web Site: http://www.sonsothunder.com/
>>
>>
>> _______________________________________________
>> use-revolution mailing list
>> use-revolution at lists.runrev.com
>> Please visit this url to subscribe, unsubscribe and manage your subscription
>> preferences:
>> http://lists.runrev.com/mailman/listinfo/use-revolution
>>
>>
Ken Ray
Sons of Thunder Software, Inc.
Email: kray at sonsothunder.com
Web Site: http://www.sonsothunder.com/
More information about the use-livecode
mailing list