本文介绍了下载诸如 mega.co.nz 之类的文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

今天我查看了 mega.co.nz,我对某些功能感到很兴奋.例如在下载页面,它会在浏览器上下载文件,然后用 javascript 解密它们.

例如,请参阅此链接以下载 png 文件:

https://mega.co.nz/#!7JRgFJzJ!efpJGWuPhYx4dRxYdGw14sR_DG4JXddeClH4

在此链接中,它将在浏览器中开始下载.我检查了检查元素中的网络选项卡,它会在完成文件的所有部分后使用 AJAX 下载部分文件,并将所有这些部分自动保存在计算机上的一个文件中!

我想知道他们是做什么的?你能解释一下或链接到一些关于在浏览器中下载文件的资源吗?

也可以只用javascript来完成还是应该使用一些flash插件或类似的东西?

Mega 使用几种不同的方法来做到这一点:(截至 2013 年 11 月 27 日)

  1. 文件系统 API(Chrome/Firefox 扩展 polyfill)
  2. Adobe Flash SWF Filewriter(旧浏览器后备)
  3. BlobBuilder (IE10/IE11)
  4. MEGA Firefox 扩展(已弃用)
  5. Arraybuffer/Blob(内存中)+ a[下载](适用于支持[下载]的浏览器)
  6. MediaSource(实验性流媒体解决方案)
  7. Blob 存储在 IndexedDB 存储中 + a[download] (Firefox 20+,对内存中的 Blob 方法的改进)

(来源:https://eu.static.mega.co.nz/js/download_6.js)

Today I checked mega.co.nz and I'm excited about some features. For example in download page it will download files on browser and after that decrypt them with javascript.

for example see this link to download a png file :

https://mega.co.nz/#!7JRgFJzJ!efpJGWuPhYczLexY19ex82nuwfs4sR_DG4JXddeClH4

in this link it will start the download inside the browser. i checked network tab in inspect element it will download parts of file with AJAX after that completed all parts of file, will save all of them in one file on computer automatically!

i want to know what they do? can you explain or link to some resource about download files inside browser like that?

also can done it only with javascript or should use some flash plugins or something like that?

解决方案

Mega uses several different methods to do this: (as of 27 Nov 2013)

  1. Filesystem API (Chrome/Firefox Extension polyfill)
  2. Adobe Flash SWF Filewriter (old browsers fallback)
  3. BlobBuilder (IE10/IE11)
  4. MEGA Firefox Extension (deprecated)
  5. Arraybuffer/Blob (in memory) + a[download] (for browsers that support a[download])
  6. MediaSource (experimental streaming solution)
  7. Blob stored in IndexedDB storage + a[download] (Firefox 20+, improvement over the in-memory Blob method)

(source: https://eu.static.mega.co.nz/js/download_6.js)

这篇关于下载诸如 mega.co.nz 之类的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-27 12:37