FileContentResult和FileStreamResult之间的区别 [英] Difference between FileContentResult and FileStreamResult

查看:901
本文介绍了FileContentResult和FileStreamResult之间的区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在编辑一些代码,并且有一种方法可以返回FileContentResult类型.我从服务中获得数据流,因此对我来说,将返回类型更改为FileStreamResult会更方便.

I'm editing some code and there is one method which return FileContentResult type. I get a stream from service, so for me it would be more convenient to change returning type to FileStreamResult.

我应该将流转换为数组以返回FileContentResult吗?

Should I convert stream to an array to return FileContentResult?

还是我可以安全地更改返回类型?

Or can I just change returning type safely?

推荐答案

FileResult是其他所有对象的抽象基类.

FileResult is an abstract base class for all the others.

  • FileContentResult-当您拥有字节数组时使用它 喜欢以文件形式返回
  • FileStreamResult-您打开了一个流,要返回它 内容作为文件
  • FileContentResult - use it when you have a byte array you would like to return as a file
  • FileStreamResult - you have a stream open, you want to return it's content as a file

这篇关于FileContentResult和FileStreamResult之间的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆