13
Il mio requisito è, dovrei inviare un file zip 10MB al client con un servizio riposante. Ho trovato il codice nei forum che l'invio di un oggetto StreamingOutput
è il modo migliore, ma come posso creare un oggetto StreamingOutput
nel codice seguente:download di file in servizi Web restful
@Path("PDF-file.pdf/")
@GET
@Produces({"application/pdf"})
public StreamingOutput getPDF() throws Exception {
return new StreamingOutput() {
public void write(OutputStream output) throws IOException, WebApplicationException
{
try {
//------
} catch (Exception e) {
throw new WebApplicationException(e);
}
}
};
}
sto avendo una domanda simile, come recuperare il file da un client REST ad esempio, per voi aplcatio, se io do http?: // localhost: 8080/urapplication/get? – parameswar
Quale riferimento stai usando per ResponseBuilder? Ho 3 potenziali riferimenti. – Lismore
@Lismore 'import javax.ws.rs.core.Response.ResponseBuilder;' - Oppure usa 'Response.ResponseBuilder' nella tua sorgente - altrimenti ho avuto lo stesso problema di te. –