REST Endpoint总是在POSTMAN中两次下载映像

时间:2019-06-10 15:59:07

标签: java spring rest spring-boot

在POSTMAN中使用Spring Boot REST Endpoint时,它总是会下载映像两次。内联/附件也不起作用,即使用作内联,也始终会下载它。这不是stackoverflow中的重复问题,因为它总是下载映像两次。

  1. 内联代码:
File invoiceImage = invoiceService.getInvoiceImage(id);
        return ResponseEntity
                .ok().header("Content-Disposition", "inline; filename=" +invoiceImage.getName()).
                contentType(MediaType.valueOf(Files.probeContentType(invoiceImage.toPath())))
                .body(Files.readAllBytes(invoiceImage.toPath()));

2。附件代码:

File invoiceImage = invoiceService.getInvoiceImage(id);
        return ResponseEntity
                .ok().header("Content-Disposition", "attachment; filename=" +invoiceImage.getName()).
                contentType(MediaType.valueOf(Files.probeContentType(invoiceImage.toPath())))
                .body(Files.readAllBytes(invoiceImage.toPath()));

0 个答案:

没有答案