Page 1 of 1

downloaded images are empty (0kb), no errors

Posted: Mon Jun 05, 2017 4:13 pm
by mattmaier
I'm trying to download images from a server to a file.

- I can view the image(s) in chrome and chrome incognito, so there shouldn't be a problem with the server, here's an example //s3.amazonaws.com/appforest_uf/f1496548544475x140387106221169240/grilled_cheese_on_plate.jpg
- I can download the image via a get/post to the server which returns the base64encoded data. I base64decode it and put it in url binfile and it works. The problem is that post is a blocking operation so the whole stack and IDE lock up.

None of the non-blocking commands are working. I've tried load, put URL, and libURLDownloadToFile. Load doesn't seem to do anything. The other two create a file in the right place with the right name but it's empty (0kb)

try
-- load tImgUrl with message "checkDownloads"
-- libURLDownloadToFile tImgUrl,tNewFile,"checkDownloads"
put URL tImgUrl into URL ("binfile:" & tNewFile)
catch myErr
answer myErr
end try

Any thoughts on what might be going wrong? Why would all of these commands fail without even generating an error?

Re: downloaded images are empty (0kb), no errors

Posted: Mon Jun 05, 2017 4:42 pm
by LiveCode_Panos
Hi Matt,

Have you tried without the leading //?

i.e. put "s3.amazonaws.com/appforest_uf/f1496548544475x140387106221169240/grilled_cheese_on_plate.jpg" into tImgUrl

Best,
Panos
--

Re: downloaded images are empty (0kb), no errors

Posted: Mon Jun 05, 2017 11:57 pm
by mattmaier
Just tried. Didn't make any difference.

Re: downloaded images are empty (0kb), no errors

Posted: Tue Jun 06, 2017 2:08 am
by FourthWorld
Wouldn't that need a service specifier, e.g. "http://"?

Re: downloaded images are empty (0kb), no errors

Posted: Tue Jun 06, 2017 4:15 am
by mattmaier
Yeah, I add "https:" to the beginning before using it.

Re: downloaded images are empty (0kb), no errors

Posted: Tue Jun 06, 2017 6:24 am
by FourthWorld
How does other software handle that URL?

Re: downloaded images are empty (0kb), no errors

Posted: Tue Jun 06, 2017 6:54 am
by SparkOut
Is this for desktop or mobile? libUrl is not implemented on mobile. You could try tsNet library though.

Re: downloaded images are empty (0kb), no errors

Posted: Wed Jun 07, 2017 7:09 pm
by mattmaier
Put the URL into the browser. It loads up the image just fine. Even in incognito mode.
I haven't even got it to download an image in the IDE; haven't thought about trying it in a standalone or mobile yet.
Just tried loading it up in the browser widget and it displays perfectly there. Just need to figure out how to download it in script.

Re: downloaded images are empty (0kb), no errors

Posted: Wed Jun 07, 2017 7:11 pm
by FourthWorld
Does the URL change from "http://" to "httos://" in the browser?

Re: downloaded images are empty (0kb), no errors

Posted: Wed Jun 07, 2017 7:13 pm
by mattmaier
Yeah, you don't need to manually add "https:" to the beginning in Chrome.

Re: downloaded images are empty (0kb), no errors

Posted: Wed Jun 28, 2017 3:32 pm
by MaxV
This works perfect on linux (livecode version 9dp6):

Code: Select all

libURLDownloadToFile "http://s3.amazonaws.com/appforest_uf/f1496548544475x140387106221169240/grilled_cheese_on_plate.jpg", "/home/max/Scrivania/test.jpg"