使用Web视图下载文件 [英] Downloading a file using web view

查看:77
本文介绍了使用Web视图下载文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在一个项目中,我想在Web视图中加载的http页面中下载mp3文件。可以通过电话驱动器或保管箱之类的应用程序打开下载的文件。

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.

当用户单击Web视图中的链接时,应将其下载到iPhone。

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

在服务器端,mp3文件位于webroot之外。因此,下载链接类似于 download.php?id = 554

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

编辑

我添加了这位代表

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 ?

推荐答案

SwiftHTTP( https:/ /github.com/daltoniam/swiftHTTP )使我成为可能!

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

这篇关于使用Web视图下载文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆