Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Downloading a file using web view

In a project, i want to download mp3 files in a http page loaded in web view. Downloaded files could be opened by apps like phone drive or dropbox.

When user click to the link in web view it should download it to iphone.

In server side, mp3 files are located outside of webroot. So, the link for download is something like "download.php?id=554"

Anyone can help me on this subject ? I wonder is there a way to achieve this. Thanks

EDIT

I added this delegate

func webView(webView: UIWebView!, shouldStartLoadWithRequest request: NSURLRequest!, navigationType: UIWebViewNavigationType) -> Bool {

        var urlm = request.URL.absoluteURL?.absoluteString

        if urlm?.rangeOfString("filename") != nil{

            print(urlm)

            //code to download (I NEED IT TOO) 

            return false
        }


    return true
    }

But still don't know how to download ?

like image 963
Utku Dalmaz Avatar asked Nov 01 '22 08:11

Utku Dalmaz


1 Answers

SwiftHTTP (https://github.com/daltoniam/swiftHTTP) made it possible to me!

like image 155
Utku Dalmaz Avatar answered Nov 11 '22 04:11

Utku Dalmaz