downloaded images are empty (0kb), no errors

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

Moderators: heatherlaine, Klaus, FourthWorld, robinmiller, kevinmiller

Post Reply
mattmaier
Posts: 109
Joined: Fri Apr 19, 2013 2:49 am

downloaded images are empty (0kb), no errors

Post by mattmaier » Mon Jun 05, 2017 4:13 pm

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?

LiveCode_Panos
Livecode Staff Member
Livecode Staff Member
Posts: 484
Joined: Fri Feb 06, 2015 4:03 pm

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

Post by LiveCode_Panos » Mon Jun 05, 2017 4:42 pm

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

mattmaier
Posts: 109
Joined: Fri Apr 19, 2013 2:49 am

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

Post by mattmaier » Mon Jun 05, 2017 11:57 pm

Just tried. Didn't make any difference.

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 6145
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

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

Post by FourthWorld » Tue Jun 06, 2017 2:08 am

Wouldn't that need a service specifier, e.g. "http://"?
Richard Gaskin
Community volunteer LiveCode Community Liaison

LiveCode development, training, and consulting services: Fourth World Systems: http://FourthWorld.com
LiveCode User Group on Facebook : http://FaceBook.com/groups/LiveCodeUsers/

mattmaier
Posts: 109
Joined: Fri Apr 19, 2013 2:49 am

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

Post by mattmaier » Tue Jun 06, 2017 4:15 am

Yeah, I add "https:" to the beginning before using it.

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 6145
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

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

Post by FourthWorld » Tue Jun 06, 2017 6:24 am

How does other software handle that URL?
Richard Gaskin
Community volunteer LiveCode Community Liaison

LiveCode development, training, and consulting services: Fourth World Systems: http://FourthWorld.com
LiveCode User Group on Facebook : http://FaceBook.com/groups/LiveCodeUsers/

SparkOut
Posts: 1792
Joined: Sun Sep 23, 2007 4:58 pm

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

Post by SparkOut » Tue Jun 06, 2017 6:54 am

Is this for desktop or mobile? libUrl is not implemented on mobile. You could try tsNet library though.

mattmaier
Posts: 109
Joined: Fri Apr 19, 2013 2:49 am

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

Post by mattmaier » Wed Jun 07, 2017 7:09 pm

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.
Last edited by mattmaier on Wed Jun 07, 2017 7:12 pm, edited 1 time in total.

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 6145
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

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

Post by FourthWorld » Wed Jun 07, 2017 7:11 pm

Does the URL change from "http://" to "httos://" in the browser?
Richard Gaskin
Community volunteer LiveCode Community Liaison

LiveCode development, training, and consulting services: Fourth World Systems: http://FourthWorld.com
LiveCode User Group on Facebook : http://FaceBook.com/groups/LiveCodeUsers/

mattmaier
Posts: 109
Joined: Fri Apr 19, 2013 2:49 am

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

Post by mattmaier » Wed Jun 07, 2017 7:13 pm

Yeah, you don't need to manually add "https:" to the beginning in Chrome.

MaxV
Posts: 1539
Joined: Tue May 28, 2013 2:20 pm
Location: Italy
Contact:

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

Post by MaxV » Wed Jun 28, 2017 3:32 pm

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"
Livecode Wiki: http://livecode.wikia.com
My blog: http://livecodeitalia.blogspot.it
To post code use this: http://tinyurl.com/ogp6d5w

Post Reply

Return to “Internet”