Home Rest Document Download
Reply: 0

Rest Document Download

fcoserper
1#
fcoserper Published in 2018-02-13 16:12:24Z

I have to retrieve documents through an API REST call. The problem is that it can return so many differents formats like pdf, word, jpg, txt...

How can I manage it? I tried something like that:

String urlBinaries = serviceUtil.URL  +
                "id/"+ request.getDocument().getUid() +"/@blob/file:content";
HttpEntity<String> httpEntityBinaries = new HttpEntity<>(nuxeoServiceUtil.createHeader());
ResponseEntity<RetrieveBinaries> responseBinaries = restTemplate.exchange(urlBinaries,
                HttpMethod.GET, httpEntityBinaries, RetrieveBinaries.class);
return responseBinaries.getBody();

The model RetrieveBinaries is like this:

public class RetrieveBinaries {
    private byte[] binaries;

    public byte[] getBinaries() {
        return binaries;
    }

    public void setBinaries(byte[] binaries) {
        this.binaries = binaries;
    }
}

This give me this error:

Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is org.springframework.web.client.RestClientException: Could not extract response: no suitable HttpMessageConverter found for response type [class com.model.RetrieveBinaries] and content type [image/jpeg]] with root cause

I'm sure there has to be some java class that is responsible for handling this problem, but I don't find it.

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.298307 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO