使用Safari在本地下载blob [英] Download blobs locally using Safari

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

问题描述

我试图找到一种跨浏览器的方式在HTML5中本地存储数据。我在Blob中生成了大量数据(请参阅MDN )。现在我想将这个Blob移动到实际的文件系统并保存到本地。我已经找到了以下方法来实现这一目标:




  • 使用< a下载> 属性。这仅适用于Chrome。

  • Microsoft在IE 10中引入了一个 saveAs 函数,可以实现这一点。

  • 在浏览器中打开Blob URL并保存。



。虽然(1)在Chrome中运行,(2)在IE中,(3)在Firefox中没有人在Safari 6中运行。下载属性尚未实现,当尝试使用URL打开blob时,Safari会抱怨URL blob:不是有效的URL。

有一个很好的脚本封装了(1)和(3) FileSaver.js ,但不能使用最新的Safari版本。



有没有一种方法可以在浏览器中以本地方式保存Blob? FileSaver.js已更新近期,它适用于IE10,Safari5 +等。

请参阅:https://github.com/eligrey/FileSaver.js/#supported-browsers


I'm trying to find a cross browser way to store data locally in HTML5. I have generated a chunk of data in a Blob (see MDN). Now I want to move this Blob to the actual filesystem and save it locally. I've found the following ways to achieve this;

  • Use the <a download> attribute. This works only in Chrome currently.
  • Microsoft introduces a saveAs function in IE 10 which will achieve this.
  • Open the Blob URL in the browser and save it that way.

None of these seems to work in Safari though. While (1) works in Chrome, (2) in IE and (3) in Firefox no one works in Safari 6. The download attribute is not yet implemented and when trying to open a blob using the URL Safari complains that URLs starting with blob: are not valid URLs.

There is a good script that encapsulates (1) and (3) called FileSaver.js but that does not work using the latest Safari version.

Is there a way to save Blobs locally in a cross browser fashion?

解决方案

FileSaver.js has beed updated recently and it works on IE10, Safari5+ etc.

See: https://github.com/eligrey/FileSaver.js/#supported-browsers

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

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