mirror of
https://github.com/valitydev/openapi-generator.git
synced 2024-11-08 11:23:58 +00:00
[C#] fix filename and Content-Disposition parsing on FileStream
This commit is contained in:
parent
89f269969d
commit
322e7a4b4b
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user