微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

.NET Core 3.1 Web Api字节数组响应被截断

如何解决.NET Core 3.1 Web Api字节数组响应被截断

我有一个API控制器,该控制器返回一个字节数组,一个CSV文件,该文件会被截断。 是否有任何配置设置会截断响应?

代码如下:

[HttpGet]
[ApiVersion("1.0")]
[Route("ProcessedData")]
[ProducesResponseType(typeof(FileContentResult),200)]
[ProducesResponseType(typeof(BusinessLogic.Dto.PagedProcessedData),200)]
[ProducesResponseType(typeof(BusinessLogic.Dto.BadRequest),400)]
public ActionResult GetProcessedData(int surveyID,int page = 1,string format = "json",DateTime? startDate = null,DateTime? endDate = null,string adm0Codes = null,int? marketID = null,string surveyType = null)
{
    try
    {

        byte[] file = Models.Repository.Survey.GetSurveyProcessedDataAsCSV(surveyID);
        if (file.Length == 0)
        {
            return BadRequest(new
            {
                Error = "No data available. Processed data becomes available after 24hrs from the upload. Please return after 24 hours."
            });
        }
        else
        {
            return File(file,"application/octet-stream","MFI-ProcessedData.csv");
            // -> it returns a truncated file,always after 1,287,168 chars.
        }
    }

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。