Page 1 of 1

libURLftpUploadFile & URLStatus

Posted: Wed Jun 20, 2007 3:49 pm
by rolandw
I have issues with uploading multiple files to a server by ftp.

put 1 into counter
repeat with i = 1 to the number of items in ftplist
put false into success
put item i of ftplist into fileName
put "ftp://myserver.mydomain.com/uploads/" & counter into theURL
libURLftpUploadFile fileName, theURL
wait for n seconds
repeat with i = 1 to 120
wait for 0.5 seconds
put URLStatus(theURL) into theURLStatus
if theURLStatus = "uploaded" then
put true into success
exit repeat
end if
end repeat
reportOnFTPSuccess(success)
end repeat

If I debug this and step thorugh it line by line then it works and the files get uploaded with URLStatus returning "uploaded". If I run it with no debugging then URLStatus either returns "connecting" or "" (ie nothing).

Any ideas?

Anyone written something easy to use that ftp's synchronously?

Posted: Wed Jun 20, 2007 4:13 pm
by BvG
liburlftpuploadfile is asynchronous.

Untested example, which does something similar to your code:

Code: Select all

on mouseUp
  put 1 into counter
  repeat for each item fileName in ftplist 
    --you'll get problems when there are itemdelimiters in your filepaths why not use lines?
    add one to counter
    put "ftp://myserver.mydomain.com/uploads/" & counter into theURL
    libURLftpUploadFile fileName, theURL, "uploadFinished"
  end repeat
end mouseUp

on uploadFinished theURL, theStatus
  if theStatus <> "uploaded" then
    put "Error: Status" && theStatus && "reported with URL:" && theURL & return after msg
  end if
end uploadFinished

Posted: Wed Jun 20, 2007 5:32 pm
by rolandw
I used the callback in a similar solution but the callback was even more unreliable than the testing of URLStatus in a simple loop. I thought that the callback would solve the problem but it didn't...

I think I'm going to have to write something to work synchronously...