我将 PDF 文件保存在 Web 应用程序外部服务器的文件夹中(出于安全原因),我需要使用 google 文档预览文件。
<iframe src="http://docs.google.com/gview?url=????&embedded=true"
style="width:718px; height:700px;" frameborder="0"></iframe>
到现在为止,我通过以文件路径作为参数的形式重定向以使它们可供下载:
string path = Request.QueryString["src"];
int index = Request.QueryString["src"].ToString().LastIndexOf("\\");
string filename = Request.QueryString["src"].ToString().Substring(index + 1);
FileStream fileStream = new FileStream(path, FileMode.Open);
int fileSize = (int)fileStream.Length;
byte[] Buffer = new byte[fileSize];
fileStream.Read(Buffer, 0, fileSize);
fileStream.Close();
Response.ContentType = ContType(path);
Response.AddHeader("content-disposition", "attachment;filename=\"" + filename);
Response.BinaryWrite(Buffer);
Response.End();
我尝试将 url 添加file.aspx?src=C:\...
为 google doc iframe 的 url 的参数,比如
http://docs.google.com/gview?url=file.aspx?src=C:\...
但它不起作用。
有没有其他方法可以将 URL 分配给流?