downloaded images are empty (0kb), no errors
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
downloaded images are empty (0kb), no errors
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?
- 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 Staff Member
- Posts: 821
- Joined: Fri Feb 06, 2015 4:03 pm
Re: downloaded images are empty (0kb), no errors
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
--
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
Just tried. Didn't make any difference.
-
- VIP Livecode Opensource Backer
- Posts: 9867
- Joined: Sat Apr 08, 2006 7:05 am
- Location: Los Angeles
- Contact:
Re: downloaded images are empty (0kb), no errors
Wouldn't that need a service specifier, e.g. "http://"?
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
Re: downloaded images are empty (0kb), no errors
Yeah, I add "https:" to the beginning before using it.
-
- VIP Livecode Opensource Backer
- Posts: 9867
- Joined: Sat Apr 08, 2006 7:05 am
- Location: Los Angeles
- Contact:
Re: downloaded images are empty (0kb), no errors
How does other software handle that URL?
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
Re: downloaded images are empty (0kb), no errors
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
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.
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.
-
- VIP Livecode Opensource Backer
- Posts: 9867
- Joined: Sat Apr 08, 2006 7:05 am
- Location: Los Angeles
- Contact:
Re: downloaded images are empty (0kb), no errors
Does the URL change from "http://" to "httos://" in the browser?
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
Re: downloaded images are empty (0kb), no errors
Yeah, you don't need to manually add "https:" to the beginning in Chrome.
Re: downloaded images are empty (0kb), no errors
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: https://livecode-blogger.blogspot.com
To post code use this: http://tinyurl.com/ogp6d5w
My blog: https://livecode-blogger.blogspot.com
To post code use this: http://tinyurl.com/ogp6d5w