With the File Manager component, I am able to upload single file. I would like to upload zip files and then uncompress the zip file on the server side so that whole folder can be uploaded to the server. How can I accomplish that in the File Manager component controller?
Amjad.
Hi Amjad,
Greetings from Syncfusion support.
In the File Manager component, you are able to upload a zip folder. But we were not clear about your exact requirement for extracting them at the server end. Whether you are using a Physical File Provider and want to extract the zip folder in your Windows Explorer Or do you want to do this folder extraction programmatically at the server end? Confirm your File Service provider to assist you promptly.
Also, we would like to let you know that we have already considered a directory (folder) upload feature in the Blazor File Manager component. Usually, Syncfusion will plan and implement the features based on feature rank, customer requested count, and volume wish-list. This will be included in any of our upcoming releases.
The status of this feature can be tracked through our feedback portal below.
You can get back to us if you need any further assistance.
Regards,
Indhumathy L
Yes we would like to extract the zip file at the server end programmatically.
Can someone please look into this and recommend a solution?
Amjad, We have achieved your requirement by customizing our Physical File Service provider's "Upload" operation. In the sample, we have used the ZipFile.ExtractToDirectory method to extract the zip file to the specified directory. Check out the below code snippet.
[PhysicalFileProvider.cs] public virtual FileManagerResponse Upload(string
path, IList { FileManagerResponse uploadResponse = new FileManagerResponse(); ... foreach (IFormFile file in uploadFiles) { if (uploadFiles != null) { var name = System.IO.Path.GetFileName(file.FileName); var fullName = Path.Combine((this.contentRootPath + path), name); ... string fileName = folders[folders.Length - 1]; var fullName = Path.Combine((this.contentRootPath + path), fileName); fullName = fullName.Replace("../", ""); ... if ((file.FileName).Split('.')[1] == "zip") { string zipPath = fullName; string extractPath = this.contentRootPath + path; //Extract the zip folder. ZipFile.ExtractToDirectory(zipPath, extractPath); //Here, we deleted the zip file which is uploaded. File.Delete(zipPath); } } } ...
return uploadResponse; } ... } |
The zipPath variable is the path of the zip file that you want to extract and extractPath is the path of the directory where you want to extract the contents of the zip file.
Sample: https://www.syncfusion.com/downloads/support/directtrac/general/ze/BlazorFileManager-230700855
Check out the attached sample and get back to us if you need any further assistance.