get the file size of a zip on a server
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
get the file size of a zip on a server
Hi All,
Is there a way to get the size file of a zip on a server ?
Best regards
Jean-Marc
Is there a way to get the size file of a zip on a server ?
Best regards
Jean-Marc
https://alternatic.ch
Re: get the file size of a zip on a server
There may be an ftp command, I'm not sure. Or you can write a little script for the server in PHP, or in LiveCode if you have LiveCode server installed, and ask the script to send the file size back.
Is this for your progress bar? If so, you can use the parameters that are sent to the urlProgress handler if your sever sends those.
Is this for your progress bar? If so, you can use the parameters that are sent to the urlProgress handler if your sever sends those.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com
HyperActive Software | http://www.hyperactivesw.com
Re: get the file size of a zip on a server
Hi Jaque,
Thank again for yours suggests.
I keep the other ways in my head (i have to study ftp command and "little script for server in PHP")
Best regards
Jean-Marc
Thank again for yours suggests.
Yes, but urlprogress is IOS only and the server has to send the total data sizeIs this for your progress bar? If so, you can use the parameters that are sent to the urlProgress handler if your sever sends those.
I search also a way to have a progressbar during a download on OSX and i thought there is a simple way to get the file size that should be useful for IOS and OSXbytesTotal - Is empty if the web server does not send the total data size.
I keep the other ways in my head (i have to study ftp command and "little script for server in PHP")

Best regards
Jean-Marc
https://alternatic.ch
Re: get the file size of a zip on a server
URLProgress works on Android too. For all desktop platforms, you can use libURLSetStatusCallback. That gives similar information, including the total byte count if your server sends that. For both urlProgress and libURLSetStatusCallback, it is helpful to set up a switch statement and catch all the status messages. When the status is "loading" you can examine the different items in the status string to see what the download byte total is. I usually see a total count on the servers I have tried so far.
Here is part of an example. In the main handler where you start the download, set the status callback:
Then LiveCode will send that message frequently during the file transfer. Write a "checkStatus" handler to catch that message and examine the parameters:
The log field should show you the status of the upload or download and if you have a progress bar it will update.
Here is part of an example. In the main handler where you start the download, set the status callback:
Code: Select all
libUrlSetStatusCallback "checkStatus", (the long id of me)
Code: Select all
on checkStatus pURL,pStatus
put pStatus & cr before fld "statusFld" -- keep a log here
switch (item 1 of pStatus)
case "uploading"
case "loading"
set the endvalue of sb "progressbar" to item 3 of pStatus
set the thumbpos of sb "progressbar" to word 1 of item 2 of pStatus -- strip space
break
case "uploaded"
case "downloaded"
set the thumbpos of sb "progressbar" to the endvalue of sb "progressbar"
-- do other processing here
break
case "error"
case "timeout"
-- do something with the error here; notify user, etc.
break
default -- contacted, requested, etc.
set the thumbpos of sb "progressbar" to 0
end switch
end checkStatus
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com
HyperActive Software | http://www.hyperactivesw.com
Re: get the file size of a zip on a server
Yes, libUrlSetStatusCallback is a better way than using the libURLDownloadToFile callback
It work fine
Thank again
Jean-Marc
It work fine
Thank again
Jean-Marc
https://alternatic.ch
Re: get the file size of a zip on a server
Hi All
I met a mistake with the downloaded message of libUrlSetStatusCallback
It seem libUrlSetStatusCallback work fine to get bytesReceived,bytesTotal but not to catch the download end which is sent before the real download is finished.
Just after the downloaded message a revZipOpenArchive (to list the zip content) return an error "ziperr,Not a zip archive"
There is a stack in attachment with the two methods. It download a zip with 50images (1.4 Mo) on the documents folder.
Meth1. Doesn't work
• using libUrlSetStatusCallback to get bytesReceived,bytesTotal for progressbar and downloaded message
Meth2. Works
• using libUrlSetStatusCallback to get bytesReceived,bytesTotal for progressbar
• using libURLDownloadToFile callback to catch the download end.
Best regards
Jean-Marc
I met a mistake with the downloaded message of libUrlSetStatusCallback
It seem libUrlSetStatusCallback work fine to get bytesReceived,bytesTotal but not to catch the download end which is sent before the real download is finished.
Just after the downloaded message a revZipOpenArchive (to list the zip content) return an error "ziperr,Not a zip archive"
There is a stack in attachment with the two methods. It download a zip with 50images (1.4 Mo) on the documents folder.
Meth1. Doesn't work
• using libUrlSetStatusCallback to get bytesReceived,bytesTotal for progressbar and downloaded message
Meth2. Works
• using libUrlSetStatusCallback to get bytesReceived,bytesTotal for progressbar
• using libURLDownloadToFile callback to catch the download end.
Best regards
Jean-Marc
- Attachments
-
- DownloadZipOSX502.livecode.zip
- (10.29 KiB) Downloaded 329 times
https://alternatic.ch
Re: get the file size of a zip on a server
Dear Jean-Marc,
Did you find a way to get remote file size ?
Koray
Did you find a way to get remote file size ?
Koray
Re: get the file size of a zip on a server
I haven't had time to look at the example stack, but the OS may need time to finalize the file download. You could try moving the unzipping to a separate handler and then calling that handler in a short amount of time.
Then add a handler "unzipFile pFilePath" and have that handler do the work.
Code: Select all
case "downloaded"
set the thumbpos of sb "progressbar" to the endvalue of sb "progressbar"
send "unzipFile <filepath> to me in 1 second
break
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com
HyperActive Software | http://www.hyperactivesw.com
Re: get the file size of a zip on a server
Hi Jacques,
Thank for your suggest. That is the trick.
Signify we don't need libURLDownloadToFile callback, LibUrlSetStatusCallback does the job
Best regards
Thank for your suggest. That is the trick.
Signify we don't need libURLDownloadToFile callback, LibUrlSetStatusCallback does the job
Best regards
https://alternatic.ch
Re: get the file size of a zip on a server
Hi Koray,
Have a look at "LibUrlSetStatusCallback" in the dictionary
""loading,bytesReceived,bytesTotal": the URL data is being received"
Jacques,
Thank for your suggest. That is the trick.
Signify we don't need libURLDownloadToFile callback, LibUrlSetStatusCallback does the job
Best regards
Yes. The last item of parameter 2 of LibUrlSetStatusCallback is the file size (when the file is loading)Did you find a way to get remote file size ?
Have a look at "LibUrlSetStatusCallback" in the dictionary
""loading,bytesReceived,bytesTotal": the URL data is being received"
Jacques,
Thank for your suggest. That is the trick.
Signify we don't need libURLDownloadToFile callback, LibUrlSetStatusCallback does the job
Best regards
https://alternatic.ch
Re: get the file size of a zip on a server
Hi All
I made a new topic "Download Zip and extract files with progressbar" for next step
http://forums.runrev.com/phpBB2/viewtop ... =8&t=13466
I made a new topic "Download Zip and extract files with progressbar" for next step
http://forums.runrev.com/phpBB2/viewtop ... =8&t=13466
https://alternatic.ch