drag and drop remote file and urlstatus problem

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

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
rezmus
Posts: 12
Joined: Fri Apr 04, 2008 11:20 am

drag and drop remote file and urlstatus problem

Post by rezmus » Sat Apr 26, 2008 5:31 pm

in my rev app there is support of placing document files on ftp server using simple upload / download buttons, but i wanted to give users possibility to just drag files in / out on some rev object to upload / down files. it's easy to do with upload coz u get with dragdata["files"] path to file and u can use it as it would be picked with answer file for example, but how to handle downloads? of course the file is on the server so u can't put remote path into dragdata["files"], and windows can't copy from remote locations. is there a way to somehow intercept drop outside rev app to be able to download file to some temp location and pass windows this temp path? if not maybe u have some other idea how it can be done?

2nd question - i want to show progress of upload download using progress bar, but when i try to get the status of for example upload started with liburlftpuploadfile i always get 'connecting' even in the middle of file transfer? it happends only for me or maybe i make something wrong?

liburlftpuploadfile tpath, tftpandfilename, "done"
wait 10 seconds
answer urlstatus(tftpandfilename)

always get connection even when transfer is really in progress.

Janschenkel
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 977
Joined: Sat Apr 08, 2006 7:47 am
Contact:

Post by Janschenkel » Sun Apr 27, 2008 6:37 pm

Hi Rezmus,

The line 'wait 10 seconds' will actually halt execution for 10 seconds - the upload doesn't proceed at the same time. That's why the last parameter is the name of a handler that you want run when the status changes.
An upload button would have a script that looks something like this:

Code: Select all

on mouseUp
  -- fill up the variables tPath and tFtpAndFilename
  ...
  -- now start uplaoding the file
  libURLftpUploadFile tPath, tFtpAndFileName, "UploadDone"
end mouseUp

on UploadDone pURL, pStatus
  -- act accordingly
end UploadDone
If you want to give the URL upload a sporting chance while using the 'wait' command, then you must use the 'wait ... with messages' form.

Code: Select all

on mouseUp
  -- fill up the variables tPath and tFtpAndFilename
  ...
  -- now start uplaoding the file
  libURLftpUploadFile tPath, tFtpAndFileName, "UploadDone"
  wait 10 seconds with messages
  answer URLStatus(tFtpAndFileName)
end mouseUp

on UploadDone pURL, pStatus
  -- act accordingly
end UploadDone
As for your first question: you should look at the 'dragStart' and 'dragEnd' messages. In your 'dragStart' handler, you can set the dragData, and then upon 'dragEnd' you can do the actual file transfer.

Hope this helped,

Jan Schenkel.
Quartam Reports & PDF Library for LiveCode
www.quartam.com

rezmus
Posts: 12
Joined: Fri Apr 04, 2008 11:20 am

Post by rezmus » Sun Apr 27, 2008 6:54 pm

tx for answer jan,

so whole dragend will be executed BEFORE dragdata will be sent to windows explorer? or it is asynchoronous, so i can do dragend script but windows will meanwhile proceed with dragdata["files"] i've set in dragstart?

rezmus
Posts: 12
Joined: Fri Apr 04, 2008 11:20 am

Post by rezmus » Mon Apr 28, 2008 7:56 am

jan,

i still can't read how many bytes i uploaded / downloaded so far with your code. i can only check that the file upload / download is done. can u tell me how to pick urlstatus during upload / download to have it as:

"loading,bytesReceived,bytesTotal": the URL data is being received
"uploading,bytesReceived,bytesTotal": the file is being uploaded to the URL

because if i use like this:

libURLftpUploadFile tPath, tFtpAndFileName, "UploadDone"
wait 10 seconds with messages
answer URLStatus(tFtpAndFileName)

i always get the answer message AFTER transfer is done (not after 10 seconds of upload / download) so it always contais "uploaded".

rezmus
Posts: 12
Joined: Fri Apr 04, 2008 11:20 am

Post by rezmus » Mon Apr 28, 2008 8:41 am

found it ;)

...
libURLftpUploadFile tPath, tFtpAndFileName, "UploadDone"
UpdateProgress
...

on UpdateProgress
if URLStatus(tFtpAndFileName) <> "uploaded" then
--update progress bar here
send UpdateProgress to me in 1 second
end if
end UpdateProgress

so now i just need to find a way to handle this download drag, because what i saw with enddrag that changing data from there doesn't change data sent to windows explorer already...

Post Reply