Git Product home page Git Product logo

Comments (10)

 avatar commented on May 15, 2024 1

👍 这份文档也提到,可以在这个方法处理下载,感谢啦~~
http://doc.mbalib.com/view/241f5e4aee6b5172fa947819d8c95a67.html

from webbrowser.

zhongwuzw avatar zhongwuzw commented on May 15, 2024

下载的功能确实没有实现,可以考虑实现一下。

from webbrowser.

 avatar commented on May 15, 2024

哈哈期待加入下载功能,同时还想请教一下实现的思路,想自己动手试试~。。~

from webbrowser.

zhongwuzw avatar zhongwuzw commented on May 15, 2024

思路就是,比如浏览器需要支持下载.zip文件,那么需要在 webView:shouldStartLoadWithRequest:navigationType:中判断navigationType类型,获取zipurl,拿到后就可以进行下载了,所以需要实现一个文件管理的界面,界面可以进行文件的管理,比如断点续传,删除等操作。

from webbrowser.

 avatar commented on May 15, 2024

在webView:shouldStartLoadWithRequest:navigationType:中截取请求的链接,那我怎么知道那些链接是可下载的呢请问?

from webbrowser.

zhongwuzw avatar zhongwuzw commented on May 15, 2024

这个问题就需要看需求了,首先,如果只需要初步实现下载功能的话,可以简单的通过后缀名,比如url后缀为.zip,那么我们可以判断他应该是一个zip文件,直接通过URLSession下载下来即可。
不过并不是每一个文件的地址都包含文件扩展名,如果需要覆盖所有的情况,有两种方法,一种是单独开一个入口,让用户输入URL,然后从响应中获取文件的名字,类型等等,HTTPheader 中有Content-DispositionContent-Type等可以获取相关信息。另一种是创建NSURLProtocol来管理所有的请求,拿到响应后的操作和第一种一样。

from webbrowser.

 avatar commented on May 15, 2024

你的意思是不是:一个链接在未加载之前是无法得知其是不是“可下载”的。要先加载它,然后拦截它的响应,从响应的header中获取到文件的类型(比如.zip),从而判断它是不是“可下载”。我理解的对吗

from webbrowser.

zhongwuzw avatar zhongwuzw commented on May 15, 2024

是的。

from webbrowser.

 avatar commented on May 15, 2024

好的,谢谢谢啦。

from webbrowser.

zhongwuzw avatar zhongwuzw commented on May 15, 2024

忘了,还有一个方法忘说,通过私有方法来判断,- (void)webView:(id)arg1 decidePolicyForMIMEType:(id)arg2 request:(id)arg3 frame:(id)arg4 decisionListener:(id)arg5;,该方法会检测到不同的Mimetype,在这个方法可以处理不同的MimeType.

from webbrowser.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.