简体   繁体   English

Servlet从远程服务器下载文件

[英]Servlet download File from remote Server

I need to create a Servlet which offers files from an external Server and sends it to the user. 我需要创建一个Servlet,该Servlet从外部服务器提供文件并将其发送给用户。

www.downloadServiceUrl.com/download/path-to-external-stored-file

as I don't want the servlet to be a "man in the middle", I need it to serve the file without pretransferring it to itself and then resubmitting it to the user for performance-issues (otherwise each download takes at least 2 times as long as it needs - not speaking about speed bottlenecks between these servers. 因为我不希望Servlet成为“中间人”,所以我需要它在不预先将文件传输给自身的情况下提供文件服务,然后将其重新提交给用户以获取性能问题(否则每次下载至少需要2次只要需要-不用说这些服务器之间的速度瓶颈。

Is this possible anyhow? 这有可能吗?

Thanks! 谢谢!

The only way I think this could be done is if your java process can access the file system where your files reside. 我认为可以完成此操作的唯一方法是,如果您的java进程可以访问文件所在的文件系统。 Your webapp can only serve files in its context, not outside, thus you need to access the file system of the external server. 您的webapp只能在其上下文中提供文件,而不能在外部提供文件,因此您需要访问外部服务器的文件系统。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM