UIWebView downloading files

Discussion in 'iOS Programming' started by csnplt, Aug 20, 2009.

  1. csnplt macrumors 6502


    Aug 29, 2008
    Chicago Area
    How can I download files with a UIWebView? By that, I mean, how can I determine if a request contains the URL for a file download, such as a .zip, .txt, .doc, .mp3, etc. file. Once I have the URL for the download, it is easy to download it using NSData. But how can I find the URL of the download.

    For example, say that a user goes to firefox.com, and clicks the Download firefox button. How could I get the URL where I can download firefox from this way? As is, my app does nothing when I click the download button. So my question is, how can I make it respond?

    I'm very new to UIWebView, and don't know HTML, so if I can't do this in UIWebView classes, how could I do it using HTML-parsing? Thanks for your help in advance.
  2. PhoneyDeveloper macrumors 68040


    Sep 2, 2008
    This is an interesting question. I wondered about it also a while ago. I don't think there is a way to do it. There is a certain amount of magic that goes on when you click a download link and I think there aren't enough callbacks from the webview to intercept this. I think that mobileSafari can do this but it's closer to the webview than we can get.

    I'm pretty sure that the identification of a download link is by a header inside the http response, it's not in the link itself. There was plenty of info on this on the web when I looked into this.

    If anyone has any bright ideas about this I'm also interested in this.

Share This Page