1

I have a rest service like this:

import org.apache.tomcat.util.http.fileupload.IOUtils;

    @RequestMapping(value = "/xxx", method = GET)
    public void getExcel(HttpServletResponse resp) {
     resp.setHeader("Content-Disposition", "attachment; filename=\"NAME.xlsx\"");
     resp.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");

            try (ServletOutputStream outputStream = resp.getOutputStream()) {
                IOUtils.copy(A-VALID-FILE-INPUT-STREAM, outputStream);
                resp.flushBuffer();
            } catch (IOException e) {
                throw new AppException(e);
            }
        }

the problem is that every time I call this service the default save name is 'response', I have tried returning HttpEntity<byte[]>, create objects like HttpHeaders() but nothing changes.

Any help is appreciated

Eduardo
  • 2,070
  • 21
  • 26
  • are you doing it in postman? postman always ask to save document with name response. – Amit Phaltankar Oct 25 '17 at 01:49
  • 1
    It seems that you want to download file by invoking the service, have you referred to this post - [download a file from Spring boot rest service](https://stackoverflow.com/questions/35680932/download-a-file-from-spring-boot-rest-service)? – LHCHIN Oct 25 '17 at 07:29
  • Yes, I am using postman, oh, is because of that? – Eduardo Oct 25 '17 at 14:23

1 Answers1

0

If you are using postman take a look at https://github.com/postmanlabs/postman-app-support/issues/2082

Seems that you will need to wait until this issue will be addressed by postman team.

Gustavo Ponce
  • 417
  • 6
  • 12