简体   繁体   English

允许用户从Azure Blob存储中下载文件作为单个zip文件

[英]allowing users to download files from azure blob storage as single zip file

I have multipl files in my blob storage. 我的Blob存储中有multipl文件。 Also I have a azure database table which stores url which points to actual individual files in blob storage . 我也有一个azure数据库表,它存储指向blob存储中实际单个文件的url。 On my webform user can specify search criteria.Then it will search for files that match the search condition and show a single link to download matching files all as a single zip file. 用户可以在我的Web表单上指定搜索条件,然后它将搜索符合搜索条件的文件,并显示单个链接以将所有匹配文件下载为单个zip文件。 I have my search results returned as a list. 我将搜索结果作为列表返回。 for example 例如
List searchresults 列出搜索结果

This search result will contain multiple urls eg.,searchresults.url ="https://myblobstorage.blob.windows.net\\xyz\\mymusic.mp3" 此搜索结果将包含多个网址,例如,.searchresults.url =“ https://myblobstorage.blob.windows.net \\ xyz \\ mymusic.mp3”

if there are matching records ,it will show a single download link on the page,so that the user can click on the link and download the the matching files together as as single zip file. 如果有匹配的记录,则会在页面上显示一个下载链接,以便用户单击该链接并将匹配的文件作为单个zip文件一起下载。

I am able generate the searchresultsList with the required file urls pointing to the files in my azure blob container. 我能够生成带有指向我的Azure Blob容器中文件的所需文件URL的searchresultsList。

Now my Question Is there a way I can generate a zip file by looping through the searchresultsList and grabbing files from blob and generate a single zip file for the user to download them? 现在我的问题 有没有办法通过遍历searchresultsList并从blob抓取文件并生成单个zip文件供用户下载的方式来生成zip文件? Give me your suggestions or some sample code to achieve this functionality. 给我您的建议或一些示例代码以实现此功能。

When the user clicks on the link, it should go and fetch all the files from corresponding urls from the search results list and generate a single zip file and download to the users machine 当用户单击链接时,它应该去从搜索结果列表中的相应URL中获取所有文件,并生成一个zip文件并下载到用户计算机上。

You need to download the blobs to your server, generat a zip and push that to the client. 您需要将Blob下载到服务器,生成一个zip并将其推送到客户端。

You can use the following lib to generate the zip file http://dotnetzip.codeplex.com/ 您可以使用以下lib生成zip文件http://dotnetzip.codeplex.com/

The blobs you can download to the client via the .NET SDK provided with the Azure framework. 您可以通过Azure框架随附的.NET SDK将Blob下载到客户端。 It should be a simple solution, really. 确实,这应该是一个简单的解决方案。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM