Download multiple files from a web api






















I tried with 2 or more document Ids but only one file was downloaded and that also is not in the correct format without extension. Zipping is the only option that will have consistent result on all browsers. Some browsers do implement it, some others don't. I think only way is that you zip your all the files and then download one zip file. I guess you can use dotnetzip package because it is easy to use. One way is that, you can first save your files on disk and then stream the zip to download.

Another way is, you can zip them in memory and then download the file in stream. Stack Overflow for Teams — Collaborate and share knowledge with a private group. Create a free Team What is Teams? Collectives on Stack Overflow. Learn more. Asked 3 years, 3 months ago. Active 6 months ago. Viewed 7k times. Split ','. Select long. Contains d. Configuration; using Microsoft. DependencyInjection; using Microsoft.

Logging; using Microsoft. Models; using System; using System. Tasks; using UploadandDownloadFiles. Use this method to add services to the container.

AddControllers ; services. Use this method to configure the HTTP request pipeline. UseDeveloperExceptionPage ; app. UseSwagger ; app. UseHttpsRedirection ; app. UseRouting ; app. UseAuthorization ; app. Http; using Microsoft.

Mvc; using System; using System. You can read more about the download attribute here. The rendered hyperlink works in all major browsers like Chrome, Edge, and Firefox.

It works like the screen recording below. Everything works as expected. We have gone over the details about downloading files via Web API. I hope you have learned something new. Thanks for reading. Senior Application Developer. I write blogs about.

Bursts of code to power through your day. Web Development articles, tutorials, and news. Sign in. Changhui Xu Follow. In both cases, the user is presented with a list of checkboxes representing a selection of files to choose from. Submitting the form will result in just those files being packaged up into one zip file and downloaded. The user selection is captured in the files parameter. The code checks to see if a file called archive. Then a folder called temp is cleared of any existing files.

Next,the selected files are copied from their source directory to the temp folder. The ZipFile. CreateFromDirectory method generates a zip file from the temp directory contents and saves it as archive.



0コメント

  • 1000 / 1000