![](/img/trans.png)
[英]How do I extract the zip code parameter from a text sent to my Twilio number?
[英]How can I extract files in my controller sent as zip file from postman
我想將一組文件上傳到azure-blob-storage中。我必須在控制器內調用上載方法時以zip格式傳遞文件(我使用郵遞員進行此調用)。盡管正在控制器內獲取壓縮數據,無法提取此壓縮數據中的文件。
下圖顯示了我如何調用api控制器並使用郵遞員傳遞zip文件。
[HttpPost]
public HttpResponseMessage PostFiles()
{
var zipfile = Request.Form.Files;
.....
如果從壓縮文件中獲取單個文件的流,則可以將該值上傳到azure blob並獲取相應的文件ID作為所需的輸出。
請提供一個解決方案,確定是否需要任何第三方dll來獲取zip文件中的各個文件詳細信息,或者無需任何第三方工具就可以解決此問題。
我認為您可以執行以下操作:
string ZipPath = Path.GetFullPath("myfile.zip"));
//ZipPath is "C:\temp\Demo\myfile.zip"
ZipArchive zipFile = ZipFile.Open(ZipPath, ZipArchiveMode.Read);
ZipArchiveEntry fileFromArchive = zipFile.GetEntry(FileName);
並使用以下名稱空間:
using System.IO.Compression;
使用SharpZipLib怎么樣? 看起來很容易使用,並且有大量的文檔和示例。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.