简体   繁体   中英

java - send a file to client by file URL without download on the server

In my web application I have a link which, when clicked, invokes an external web service to retrieve a download URL for a file.

I need to send back to client the file which is beyond this URL, instead of the download URL retrieved from the web service. If possible, I would also like to do it without having to download the file on my server beforehand.

I've found this question about a similar task, but which used PHP with the readfile() function. Is there a similar way to do this in Java 8?

If you doesn't even want to handle that file you should answer the request with a redirect (eg HTTP 301 or 302). If you want to handle the file you should read the file in a byte buffer and send it to the client which would make the transfer slower. Without seeing your implementation so far, this is my best suggest.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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