0

我有一个 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(这是我希望从这里(或最终在云端)交付内容的偏好),那么在我看到 iOS 中的进度条之前会有很大的延迟。我猜这是因为我必须在返回文件之前从 AWS 流式传输文件,但我无法想出更好的方法。

有没有办法可以在收到流时逐渐发送流?

任何帮助表示赞赏!

4

1 回答 1

-1

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

于 2013-09-26T07:57:29.270 回答