Download not working with link or libURLDownloadToFile

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

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
Ken3D
Posts: 16
Joined: Sun Mar 02, 2014 12:54 am

Download not working with link or libURLDownloadToFile

Post by Ken3D » Mon Mar 10, 2014 8:38 pm

I can't get files to download from my browser app. I'm using revBrowser and its working great to host web pages in my LC project - but when I click on a download link on the page nothing happens. The files download fine when using Safari or Firefox, but inside LC no.

I added a function that uses the libURLDownloadToFile command to see if that would force the file to download but I'm still not seeing anything happen. The code I'm using for this is:

Code: Select all

on browserDownloadRequest sBrowserId, pUrl
   answer pUrl
   libURLDownloadToFile pUrl, specialFolderPath("desktop")
   answer question "To download files you'll need to swich to an external browser application. Would you like to do that now?" with "Not Now" or "Yes" titled "Go to browser to download?"
   if it is "Yes" then
      launch url urlCache
   end if
   abIamNotBusy
end browserDownloadRequest
The "browserDownloadRequest" catches the request and runs the above code. I'm using the "answer pUrl" in there just so I can see what the requested download URL is to make sure it's correct. You can see I also added the answer question asking the user if they want to use an external browser just because I haven't been able to get direct downloading to work.

I would post the URL for the page with the download link but the forum is telling me I don't have permission to post URLs - but its a standard web address with the last entry in the line a .zip file name.

Is there some initialization I need to do in order to get downloads to work in revBrowser? What am I missing? I've tried this on two MacBook Pros - one running Mavericks and the other 10.7.5.

Thanks.

BvG
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 1236
Joined: Sat Apr 08, 2006 1:10 pm
Location: Zurich
Contact:

Re: Download not working with link or libURLDownloadToFile

Post by BvG » Mon Mar 10, 2014 9:27 pm

As far as I can read in the dictionary, browserDownloadRequest is more of a notification that the browser will now download a file, and you don't need to do anything... at least on Mac OS X.

In addition you're trying to download the url twice in the code too! (launch vs liburldownladotofile) But that might be from trying so many things?
Various teststacks and stuff:
http://bjoernke.com

Chat with other RunRev developers:
chat.freenode.net:6666 #livecode

Ken3D
Posts: 16
Joined: Sun Mar 02, 2014 12:54 am

Re: Download not working with link or libURLDownloadToFile

Post by Ken3D » Mon Mar 10, 2014 9:46 pm

Thanks for the quick responses - first to you BvG: [well - there was another response here but now it's gone - so just responding to BvG]
Yeah, I only added the function that utilizes the browserDownloadRequest message because downloads weren't working. That function first started as just the notification to the user giving them the option to go to their default browser to download the file - like this:

Code: Select all

on browserDownloadRequest sBrowserId, pUrl
   answer question "To download files you'll need to swich to an external browser application. Would you like to do that now?" with "Not Now" or "Yes" titled "Go to browser to download?"
   if it is "Yes" then
      launch url urlCache
   end if
   abIamNotBusy
end browserDownloadRequest
You're right that I'm trying to download twice - but I believe the first request is the link in the web page (the revBrowser should allow that to happen) but when I saw that the first one wasn't working I tried the libURLDownloadToFile command to see if that would work - but no go. I suppose you could argue there's a third download request - but that one is optional for the user and takes them to their default browser - and in that case it only takes them to the page with the download link (that's what the urlCache is for - it's holding the URL for the page the download link is on).

Did I misunderstand your response BvG?

BvG
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 1236
Joined: Sat Apr 08, 2006 1:10 pm
Location: Zurich
Contact:

Re: Download not working with link or libURLDownloadToFile

Post by BvG » Mon Mar 10, 2014 9:58 pm

I tried to say that you should read the dictionary entry, and not try to do random things 8)

You say that the download, as initiated within the browser instance is not starting, despite the same link/url working from a normal safari window. the dictionary says it should start. If all that is right, then I suggest you file a bug report:

http://quality.runrev.com

Don't forget to include a simple to follow step by step guide.
Various teststacks and stuff:
http://bjoernke.com

Chat with other RunRev developers:
chat.freenode.net:6666 #livecode

Ken3D
Posts: 16
Joined: Sun Mar 02, 2014 12:54 am

Re: Download not working with link or libURLDownloadToFile

Post by Ken3D » Tue Mar 11, 2014 12:03 am

Bug submitted. Is there anyone out there who is finding success doing downloads of a .zip file from the revBrowser on a Mac?

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am
Location: Palo Alto

Re: Download not working with link or libURLDownloadToFile

Post by Simon » Tue Mar 11, 2014 12:41 am

I wonder if it has to do with no filename?
libURLDownloadToFile pUrl, specialFolderPath("desktop")
Does not specify it.
You'd get the filename from
set itemDel to "/"
put the last item of pUrl into tName
libURLDownloadToFile pUrl, specialFolderPath("desktop") & "/" & tName.

Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7215
Joined: Sat Apr 08, 2006 8:31 pm
Location: Minneapolis MN
Contact:

Re: Download not working with link or libURLDownloadToFile

Post by jacque » Tue Mar 11, 2014 8:06 am

Also, the variable 'urlcache' has no value that I can sse.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

Ken3D
Posts: 16
Joined: Sun Mar 02, 2014 12:54 am

Re: Download not working with link or libURLDownloadToFile

Post by Ken3D » Tue Mar 11, 2014 9:11 am

jacque wrote:Also, the variable 'urlcache' has no value that I can sse.
That variable is a global and is filled with the URL earlier in another function in my script. I apologize that the code I pasted here is not fully self contained - I realize that makes it difficult to follow what I'm saying.

Ken3D
Posts: 16
Joined: Sun Mar 02, 2014 12:54 am

Re: Download not working with link or libURLDownloadToFile

Post by Ken3D » Tue Mar 11, 2014 9:14 am

Simon - thanks for the ideas and code snippet. I'll have to take some time to look up some of what you're suggesting using the LC dictionary to see if can follow what your saying. I think I am providing a proper path and URL in my code - but maybe not.

istech
Posts: 194
Joined: Thu Sep 19, 2013 10:08 am

Re: Download not working with link or libURLDownloadToFile

Post by istech » Thu Jun 05, 2014 1:34 pm

I have had a few issues using LibURLDownloadToFile to get a download. As I was playing around I decided to try to "lock screen" before calling the "LibURLDownloadToFile" and it worked a lot better. This maybe my case with my code but worth a try good luck.

Post Reply

Return to “Internet”