[英]Upload Largefile to Azure Blob using Javascript
I have seen few examples where a file is transferred to server side and then uploaded to Azure Blob Storage.我见过几个将文件传输到服务器端然后上传到 Azure Blob 存储的示例。
But I have files with size in few GBs.但是我有几 GB 大小的文件。
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.有没有一种方法可以使用客户端脚本将文件直接上传到 Azure Blob 存储,而不是从服务器端上传以节省时间。
Updating my answer, now that CORS is supported in Windows Azure Storage and the OP has not accepted any answer :).更新我的答案,现在 Windows Azure 存储支持 CORS 并且 OP 没有接受任何答案:)。
Yes, it is possible to upload large files directly from your browser to Windows Azure Storage.是的,可以将大文件直接从浏览器上传到 Windows Azure 存储。 You may find these steps useful:
您可能会发现这些步骤很有用:
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.首先创建一个
Shared Access Signature URL (SAS)
,至少对要在其中上传文件的 blob 容器具有Write
权限。 Since you're uploading large files, I would recommend keeping SAS expiry time to be long enough.由于您要上传大文件,我建议您将 SAS 到期时间保持足够长。
Next enable CORS on your storage account.接下来在您的存储帐户上启用 CORS。 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/ .
如果您希望以编程方式进行,您可能会发现这篇文章很有用: 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.如果你想使用一个工具,我公司已经发布了一个
Free
工具来做到这一点。 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/ .您可以阅读有关此工具的更多信息并从此处下载: http : //blog.cynapta.com/2013/12/cynapta-azure-cors-helper-free-tool-to-manage-cors-rules-for-windows-天蓝色斑点存储/ 。
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/ .我写了一篇关于将非常大的文件上传到 blob 存储的博客文章,您可以在这里阅读: 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.
在您的存储帐户上启用 CORS 后,博客中提到的代码应该可以正常工作。
Azure released Storage JavaScript client library for browsers. Azure发布了用于浏览器的Storage JavaScript客户端库。 https://azure.microsoft.com/en-us/blog/new-azure-storage-javascript-client-library-for-browsers-preview/
https://azure.microsoft.com/zh-CN/blog/new-azure-storage-javascript-client-library-for-browsers-preview/
Guide and samples are here: https://dmrelease.blob.core.windows.net/azurestoragejssample/samples/sample-blob.html 指南和示例在这里: https : //dmrelease.blob.core.windows.net/azurestoragejssample/samples/sample-blob.html
Also a simple demo here to upload a blob to a container using SAS token. 这也是一个使用SAS令牌将Blob上传到容器的简单演示。 https://authinazuread.azurewebsites.net/storage.html
https://authinazuread.azurewebsites.net/storage.html
It's all client side javascript, so files are not transferred to server. 这些都是客户端javascript,因此文件不会传输到服务器。 It supports chunked upload and works well with large files.
它支持分块上传,并且可以很好地处理大型文件。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.