More libURLDownloadToFile problems

LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
rjenkinsgb
Posts: 12
Joined: Tue Feb 17, 2015 1:30 pm

More libURLDownloadToFile problems

Post by rjenkinsgb » Wed May 06, 2015 10:27 am

Two problems:

First:
The IDE keeps "losing" libURLDownloadToFile - I can sometimes do a minor change somewhere in my project and livecode will suddenly decide it cannot find that function.

At that point it also will not build the app (targeted to Android).

Sometimes, changing standalone app settings & changing back again works, but not always.

The same project works if opened in livecode 6. Usually, saving it and opening in 7 again then works...


Second:
I'm using the line
libURLDownloadToFile lqurl, lqpath, "dlDone"

to pull images from a server.

This works fine in the IDE and the callback is triggered on completion.

Initially I was just pulling files and assuming it worked if the file name appeared in the appropriate directory.
However, if an image file was corrupt or incomplete it corrupts the device screen when displayed.


I've changed to using an sqlite database to keep track of file requests, so I now give the files a temporary name to prevent them being used prematurely, then rename them when the download complete callback occurs.

That works perfectly in the IDE, but on the device it never gets any callbacks so the files are never renamed.

I've added a log field & I'm storing the result of every callback, whether successful or not.
Again, in the IDE I see the URLs and "downloaded" status - but nothing at all on the device, not one single result.

Something appears seriously broken and I'm at a loss as to how and work around it. The principle of the app is to fetch and display image data and with no way of knowing if a particular file has been downloaded successfully, it simply cannot function..

Any ideas appreciated!

RJ.

rjenkinsgb
Posts: 12
Joined: Tue Feb 17, 2015 1:30 pm

Re: More libURLDownloadToFile problems

Post by rjenkinsgb » Thu May 07, 2015 5:43 pm

I was just going to post a bug report for this & found one already exists - # 11504 originally date November 2013.

rjenkinsgb
Posts: 12
Joined: Tue Feb 17, 2015 1:30 pm

Re: More libURLDownloadToFile - Work around

Post by rjenkinsgb » Fri May 08, 2015 12:36 pm

A way of getting a similar functionality with other commands:

Use
load URL [url] with message "callback"
to queue a download for the required file.

That appears to be non-blocking and multiple files can be queued.

In the callback routine, use cachedURLs() to get a list of urls in the queue.

Work through that and use URLstatus() on each to find the ones with a status of "cached" - that means a successful download has completed.

For those, use putURL on the url to use or save the content, then
unload URL in the url to clear it from the cache.

For the urls with a status of error, timeout or no found, you have unload them and decide whether to attempt another load or just fail them.

charms
Posts: 122
Joined: Mon Feb 10, 2014 6:21 pm
Location: Singapore
Contact:

Re: More libURLDownloadToFile problems

Post by charms » Wed May 20, 2015 11:58 pm

I had some issues too. To check if the download is complete and download each file after the other you can do following:

Code: Select all

local sDownloadComplete

libURLSetSSLVerification false
libURLDownloadToFile tUrl, tDest, "ee.config.downloadComplete"
wait until _ee.config.getDownloadStatus() is "Download complete" with messages

private function _ee.config.getDownloadStatus
   if sDownloadComplete is "Download complete" then
      put empty into  sDownloadComplete 
      return "Download complete"
   else
      return sDownloadComplete
   end if
end _ee.config.getDownloadStatus

private command _ee.config.setDownloadStatus pVal
   put pVal into sDownloadComplete
end _ee.config.setDownloadStatus

on ee.config.downloadComplete pUrl, pStatus
   put "Download complete" into sDownloadComplete
end ee.config.downloadComplete

rjenkinsgb
Posts: 12
Joined: Tue Feb 17, 2015 1:30 pm

Re: More libURLDownloadToFile problems

Post by rjenkinsgb » Thu May 21, 2015 12:52 pm

There are possibly other problems with the internet library, or it's proper inclusion in builds.

I submitted a bug report yesterday using a minimal code sample posted by one of the Livecode team as an explanation of something; just a few lines but including a "load url" and it's callback.

That works fine in the IDE but gives no result when built as an android app with LC7 and it won't even build with LC6.

Just waiting for the Livecode people to look at it.

(Building on a Mac).

Post Reply

Return to “Getting Started with LiveCode - Experienced Developers”