Question

I am developing a web-app that needs to query an ontology through a REST-API. If I call the API through the browser, it opens a pop-up "Save As" through which I can save the file. This is because the header of the response contains:

Content-Disposition: attachment; filename = query-result.srx

The problem is that I would like to receive the file within my web-app without using the browser. The web-app is write on java and I use Apache HttpClient for send and receive, HTTP request and response:

CloseableHttpClient httpClient = HttpClients.createDefault();
HttpGet httpGet = new HttpGet(uri);
CloseableHttpResponse httpResponse = httpClient.execute(httpGet);

If I try to get the entity's content:

httpResponse.getEntity().getContent()

It return a useless value.

It 's something that you can do with this library, or should I use another library.

I found another question similar to mine but no one answered.

java-javascript-read-content-disposition-file-content

Thanks to all who answer me!

Was it helpful?

Solution

I realized that the error was in the query that I used the REST API. So the operations I did in Java were correct. With the command

httpResponse.getEntity().getContent() 

you can take the content that is returned even if this file is described in the content-disposition.

Thanks to @Julian Reschke

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top