Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/reporting-services/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
从AWS返回文件与从iOS返回FileStream之间的区别_Ios_Asp.net Mvc_Amazon Web Services_Amazon S3 - Fatal编程技术网

从AWS返回文件与从iOS返回FileStream之间的区别

从AWS返回文件与从iOS返回FileStream之间的区别,ios,asp.net-mvc,amazon-web-services,amazon-s3,Ios,Asp.net Mvc,Amazon Web Services,Amazon S3,我有一个MVC控制器,它将PDF文档作为文件返回。此文件下载到iOS报摊应用程序中 public ActionResult GetPdf(string id) { //Local //string fileName = Server.MapPath("/NewsstandPDFs/" + id + ".pdf"); //FileInfo info = new FileInfo(fileName); //return File(info.OpenRead(), "application/pdf")

我有一个MVC控制器,它将PDF文档作为文件返回。此文件下载到iOS报摊应用程序中

public ActionResult GetPdf(string id)
{
//Local
//string fileName = Server.MapPath("/NewsstandPDFs/" + id + ".pdf");
//FileInfo info = new FileInfo(fileName);
//return File(info.OpenRead(), "application/pdf");

//WORKING FROM S3
System.IO.MemoryStream data = new System.IO.MemoryStream();
System.IO.Stream str = StorageFacade.getstream("NewsStandPdfs/" + id.ToUpper() + ".pdf", StorageScope.BigImages, null);
str.Seek(0, SeekOrigin.Begin);  //This rewinds the stream.
return new FileStreamResult(str, "application/pdf");
}

本地文件版本非常好用,在IOS中,我可以使用进度条显示下载进度

但是,如果我使用AWS S3,这是我的首选,因为我希望最终从这里或cloudfront交付内容,在我看到进度条在iOS中工作之前,会有一个明显的延迟。我猜这是因为我必须在返回文件之前从AWS流式传输文件,但我无法找到更好的方法

是否有一种方法可以在收到流时逐渐发送流


感谢您的帮助

如果您希望从S3/Cloudfront提供此内容,那么为什么要将其放入asp.net应用程序,然后发送到客户端?
另一种方法是在asp.net应用程序中准备链接,然后让iOS客户端直接从S3获取链接/CF.

,因为我需要.net使用成员资格工具处理文件保护。我知道您可以从S3等内部执行一些级别的保护,但我不想在两个方面进行管理。有什么建议吗?有。在asp.net中执行所有身份验证/授权逻辑-一旦您满意,然后创建一个指向s3的预签名临时链接,该链接将在几分钟后过期,并使用该特殊url重定向/打开一个新窗口。请看:好的,这很有效,而且很有意义,因为它不会锁定iOS。我现在唯一的问题是,由于该文件尚未下载,似乎无法在我的界面上显示进度条,因为我不知道它的大小(以字节为单位)。有什么想法吗?