当前位置: 代码网 > 服务器>服务器>ftp服务器 > ftp服务器PDF文件在线查看的实现方法

ftp服务器PDF文件在线查看的实现方法

2024年05月18日 ftp服务器 我要评论
url形式:// http://localhost:2692/pdfviewer/web/viewer.html?file=http://localhost:2692/tov/dasystem

url形式:

// http://localhost:2692/pdfviewer/web/viewer.html?file=http://localhost:2692/tov/dasystem/getstreaem?path%3dftp://ftp账号:ftp密码@ip地址/0001/e_file3/2017526/test.pdf

注意:pdfviewer/web/viewer.html是一个pdf插件地址链接

后台方法,将ftp服务器上的pdf文件转成二进制流进行读取

using system.net;

public filestreamresult getstreaem(string path)
{
var reqftp = (ftpwebrequest)webrequest.create(new uri(path));
reqftp.method = webrequestmethods.ftp.downloadfile;
reqftp.usebinary = true;
//reqftp.credentials = new networkcredential(ftpuserid, ftppassword);
reqftp.usepassive = false; //选择主动还是被动模式 , 这句要加上的。
reqftp.keepalive = false;//一定要设置此属性,否则一次性下载多个文件的时候,会出现异常。
var response = (ftpwebresponse)reqftp.getresponse();
var ftpstream = response.getresponsestream();
return file(ftpstream, "application/pdf", "ib70guide.pdf");
}

以上这篇ftp服务器pdf文件在线查看的实现方法就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持代码网。

(0)

相关文章:

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

发表评论

验证码:
Copyright © 2017-2025  代码网 保留所有权利. 粤ICP备2024248653号
站长QQ:2386932994 | 联系邮箱:2386932994@qq.com