Curl and FTP upload

Hi All,
I have successfully used to curl in applescript to upload files, however, I would love to have it read the amount of bytes loaded vs the total amount to give me an active update so a client can tell how long they have to wait until their file is completely uploaded.

Is it possible to read the file info off the ftp server and then knowing the total bytes of the files, create a loading bar or a updated message. Perhaps a repeat while loop?

Thank you

I believe there is. I’m looking through the man pages.

Hi Dylan,
Thanks for the reply. So, you think there is a call in the curl man pages to read and report the file size? If so, I suppose then, I could have a repeat loop reading it until it is complete.

THanks for your help.

I’m looking… BUT I CAN’T FIND ANYTHING!!! I know cURL has SOMETHING!!! I KNOW! :mad:

There is a way… The rough idea is to dump the verbose into a text file somewhere and read it’s output. But I don’t see how you would do that with simple AS… difficult to do with AS Studio. Also, depends on wether you are uploading or downloading files. For example, for downloading, I settled with reading the file’s size constantly to have an idea of the progress… as for uploading, same thing, but in reverse… sounds simple when saying it, but not that easy to do because you have to simulate multi-tasking in a single-task language.

If you need the details, i’ll have to dig in my apps and find the routine. But I only got the download to work, havent finished with upload yet, had to concentrate my efforts somewhere else for the moment. Eventually will get it to work!

Browser: Safari 531.22.7
Operating System: Mac OS X (10.6)

FWIW, it sounds like a good candidate for doing as an NSTask in AppleScriptObjC.

Yeah, i’m sure it is way easier than what I found in AS Studio! I’d be curious to experiment on that… but until the company I work for switches to 10.6, I sadly can’t spend all my time learning ASOC. Can’t wait! :slight_smile:

Browser: Safari 531.22.7
Operating System: Mac OS X (10.6)

Thanks,
I will have more of a peek. I am trying to figure things out and learn Objective C. THe more I do, I realize how little i know. Just have to keep working on it. Thanks so much.

Here’s the rough version of what I used to keep track of a download… it write a log of the transfer in progress to a folder of my choice. You will have to cut out the bad things and figure out the rest yourself, but it is a good start:

set downloadLog to (defaultZIPtoFolderPath & "log_" & (random number from 10000 to 1000000)) as string

set thePidID to do shell script ("curl " & (quoted form of theFileToDownloadPath) & " -o " & (quoted form of downloadFileToPath) & " -m 9000 > " & (quoted form of downloadLog) & " 2>&1 & echo $!") as string

tell me to log ("thePidID : " & thePidID) as string

It also logs the Pid ID of the curl process, because this command launches it in the background, so your app has to keep track of the process to know if it is still running, kill it, etc…

This:

2>&1 & echo $!

is where all the magic happens… you will be able to find more info if you search through these forums.

Helps?

Browser: Safari 531.9
Operating System: Mac OS X (10.6)

I will give it a try. Thank you