使用Javascript上传Largefile天青斑点 [英] Upload Largefile to Azure Blob using Javascript

查看:183
本文介绍了使用Javascript上传Largefile天青斑点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经看到了文件的传送到服务器端,然后上传到Azure的Blob存储几个例子。结果
但我有文件,在几个GB的大小。结果
有没有一种方法,我可以使用客户端脚本,而不是从服务器端做的,以节省时间直接将文件上传到Azure的Blob存储。


解决方案

更​​新我的回答,现在CORS在Windows Azure存储支持和OP没有接受任何的答案。)

是的,这可以从浏览器到Windows Azure存储直接上传大文件。您可能会发现这些步骤有用:


  1. 首先创建一个共享访问签名URL(SAS)至少许可的BLOB容器,你要上传的文件。既然你要上传大文件,我会建议保持SAS到期时间足够长。


  2. 接下来让您的存储账户CORS。如果你想以编程方式做到这一点,你会发现这个帖子有用:<一href=\"http://gauravmantri.com/2013/12/01/windows-azure-storage-and-cors-lets-have-some-fun/\">http://gauravmantri.com/2013/12/01/windows-azure-storage-and-cors-lets-have-some-fun/.如果你想使用一个工具,我公司已经发布了 免费 工具来做到这一点。你可以阅读更多有关此工具,并从这里下载:<一href=\"http://blog.cynapta.com/2013/12/cynapta-azure-cors-helper-free-tool-to-manage-cors-rules-for-windows-azure-blob-storage/\">http://blog.cynapta.com/2013/12/cynapta-azure-cors-helper-free-tool-to-manage-cors-rules-for-windows-azure-blob-storage/.


  3. 我写了一篇博客文章一些时间重新上传非常大的文件到Blob存储,您可以在这里阅读:<一href=\"http://gauravmantri.com/2013/02/16/uploading-large-files-in-windows-azure-blob-storage-using-shared-access-signature-html-and-javascript/\">http://gauravmantri.com/2013/02/16/uploading-large-files-in-windows-azure-blob-storage-using-shared-access-signature-html-and-javascript/.一旦CORS是您的存储账户启用后,在博客中提到的code应该只是罚款。



其实有一个办法,虽然也有一些preconditions /警告。

  1. 由于CORS不Blob存储支持,只是还没有,你的HTML和JS文件需要在同一个Blob存储帐户present。他们应该是在一个公开的blob容器。

  2. 既然你要上传大文件,他们将需要分割成块小于4 MB的大小。 HTML 5有一个文件API,它可以将文件分割成块,但并不是所有的浏览器都支持此功能。


我写了一篇博客文章前一段时间有关上传使用纯JavaScript和共享访问签名的大型文件。你可以在这里读到一篇: http://gauravmantri.com/2013/02/16/uploading-large-files-in-windows-azure-blob-storage-using-shared-access-signature-html-and-javascript.

I have seen few examples where a file is transferred to server side and then uploaded to Azure Blob Storage.
But I have files with size in few GBs.
Is there a way I can upload a file directly to Azure Blob Storage using Client Side scripts instead of doing it from Server Side to save time.

解决方案

Updating my answer, now that CORS is supported in Windows Azure Storage and the OP has not accepted any answer :).

Yes, it is possible to upload large files directly from your browser to Windows Azure Storage. You may find these steps useful:

  1. First create a Shared Access Signature URL (SAS) with at least Write permission on the blob container in which you wish to upload the files. Since you're uploading large files, I would recommend keeping SAS expiry time to be long enough.

  2. Next enable CORS on your storage account. If you wish to do it programmatically, you may find this post useful: http://gauravmantri.com/2013/12/01/windows-azure-storage-and-cors-lets-have-some-fun/. If you want to use a tool, my company has released a Free tool to do just that. You can read more about this tool and download from here: http://blog.cynapta.com/2013/12/cynapta-azure-cors-helper-free-tool-to-manage-cors-rules-for-windows-azure-blob-storage/.

  3. I wrote a blog post some time back on uploading very large files into blob storage which you can read here: http://gauravmantri.com/2013/02/16/uploading-large-files-in-windows-azure-blob-storage-using-shared-access-signature-html-and-javascript/. Once CORS is enabled on your storage account, code mentioned in the blog should work just fine.

Actually there's a way though there are some preconditions/caveats.

  1. Because CORS is not supported in Blob Storage just yet, your HTML and JS file need to be present in same blob storage account. They should be in a public blob container.
  2. Since you're uploading large files, they would need to be split into chunks less than 4 MB in size. HTML 5 has a File API which can split the file into chunks but not all browsers support this feature.

I wrote a blog post some time ago about uploading large files using pure JavaScript and Shared Access Signature. You can read that post here: http://gauravmantri.com/2013/02/16/uploading-large-files-in-windows-azure-blob-storage-using-shared-access-signature-html-and-javascript.

这篇关于使用Javascript上传Largefile天青斑点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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