-
-
Notifications
You must be signed in to change notification settings - Fork 82
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bug in Download Response headers #55
Comments
@mansai I think it should be the following
|
@mansai Ok, I have reproduced the problem, you can first use the following code snippet to return your expected result.
|
@mansai I'm sorry I can't reproduce your results. I do n’t know if you have executed |
@mansai Thanks for the feedback! I appreciate it. This should now be resolved with the latest release here: https://www.nuget.org/packages/AutoWrapper.Core/4.2.0 Sample usage: [HttpGet("getfile")]
[AutoWrapIgnore]
public FileStreamResult GetFile2()
{
var filePath = $"{Environment.CurrentDirectory}/Logs/log_20200501.txt";
var file = System.IO.File.OpenRead(filePath);
var provider = new FileExtensionContentTypeProvider();
var fileInfo = new System.IO.FileInfo(filePath);
var memi = provider.Mappings[fileInfo.Extension];
return File(file, memi, fileInfo.Name);
}
[HttpGet("getfile2")]
[AutoWrapIgnore]
public FileStreamResult GetFile()
{
var path = $"{Environment.CurrentDirectory}/Logs/log_20200501.txt";
var stream = System.IO.File.OpenRead(path);
return new FileStreamResult(stream, "application/octet-stream");
}
[HttpGet("getpdf")]
[AutoWrapIgnore]
public IActionResult GetPdf()
{
var path = $"{Environment.CurrentDirectory}/sample.pdf";
byte[] fileBytes = System.IO.File.ReadAllBytes(path);
return new FileContentResult(fileBytes, "application/pdf");
}
[HttpGet("getpdf2")]
[AutoWrapIgnore]
public IActionResult GetPdf2()
{
var path = $"{Environment.CurrentDirectory}/sample.pdf";
var stream = new FileStream(path, FileMode.Open);
return new FileStreamResult(stream, "application/pdf");
}
//returns text/plain
[HttpGet("getstring")]
[AutoWrapIgnore]
public ContentResult GetString()
{
return Content("Hello");
} |
txt file download ok,Unable to open Excel or pdf,content-length changed |
I've released v4.2.2 here: https://www.nuget.org/packages/AutoWrapper.Core/4.2.2 Please update to that and it should fix the issue. Thanks! |
[HttpPost]
[AutoWrapIgnore]
public async Task< FileStreamResult> GetExcel()
{
var filePath = "xxx..xlsx";
var file = System.IO.File.OpenRead(filePath);
var provider = new FileExtensionContentTypeProvider();
var fileInfo = new System.IO.FileInfo(filePath);
var memi = provider.Mappings[fileInfo.Extension];
return File(file, memi, fileInfo.Name);
}
Bug:
content-type: application/json
Right:
content-type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
The text was updated successfully, but these errors were encountered: