libURLftpUploadFile & URLStatus

Bringing the internet highway into your project? Building FTP, HTTP, email, chat or other client solutions?

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
rolandw
Posts: 11
Joined: Tue Oct 24, 2006 8:47 am

libURLftpUploadFile & URLStatus

Post by rolandw » Wed Jun 20, 2007 3:49 pm

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?

BvG
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 1236
Joined: Sat Apr 08, 2006 1:10 pm
Location: Zurich
Contact:

Post by BvG » Wed Jun 20, 2007 4:13 pm

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
Various teststacks and stuff:
http://bjoernke.com

Chat with other RunRev developers:
chat.freenode.net:6666 #livecode

rolandw
Posts: 11
Joined: Tue Oct 24, 2006 8:47 am

Post by rolandw » Wed Jun 20, 2007 5:32 pm

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...

Post Reply

Return to “Internet”