From 322e7a4b4bd20eb431b4b09d06eaf0d88eda97ff Mon Sep 17 00:00:00 2001 From: hacki11 Date: Tue, 15 Dec 2015 23:33:48 +0100 Subject: [PATCH] [C#] fix filename and Content-Disposition parsing on FileStream --- .../src/main/resources/csharp/ApiClient.mustache | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/modules/swagger-codegen/src/main/resources/csharp/ApiClient.mustache b/modules/swagger-codegen/src/main/resources/csharp/ApiClient.mustache index db865e2b27..1b49d9b534 100644 --- a/modules/swagger-codegen/src/main/resources/csharp/ApiClient.mustache +++ b/modules/swagger-codegen/src/main/resources/csharp/ApiClient.mustache @@ -233,12 +233,15 @@ namespace {{packageName}}.Client ? Path.GetTempPath() : Configuration.TempFolderPath; var regex = new Regex(@"Content-Disposition:.*filename=['""]?([^'""\s]+)['""]?$"); - var match = regex.Match(headers.ToString()); - if (match.Success) + foreach (var header in headers) { - string fileName = filePath + match.Value.Replace("\"", "").Replace("'", ""); - File.WriteAllBytes(fileName, data); - return new FileStream(fileName, FileMode.Open); + var match = regex.Match(header.ToString()); + if (match.Success) + { + string fileName = filePath + match.Groups[1].Value.Replace("\"", "").Replace("'", ""); + File.WriteAllBytes(fileName, data); + return new FileStream(fileName, FileMode.Open); + } } } var stream = new MemoryStream(data);