java - REST Endpoint 总是在 POSTMAN 中下载图像两次
问题描述
在 POSTMAN 中使用时,Spring boot REST Endpoint 总是下载两次图像。内联/附件也不起作用,即使用作内联也总是下载它。这不是 stackoverflow 中的重复问题,因为它总是下载图像两次。
- 内联代码:
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()));
解决方案
推荐阅读
- pytorch - Pytorch nn.parallel.DistributedDataParallel 模型加载
- postgresql - 在查询中获取最高和最低价格和卖家
- visual-studio - Visual Studio Code 总是以某种“检查”模式启动
- java - Spring Batch + JPA + PostgreSQL 当前事务被中止,命令被忽略直到事务块结束
- asp.net-core - Rest api,将 cookie 设置为 blazor wasm 客户端
- laravel - 试图获取非对象的属性“总计”(laravel 和 vue)
- javascript - 如何生成 0.1 到 46.61 之间的序列,间隔为 0.1
- swift - UIButton 标题“Button”从属性检查器中删除后未清除
- wordpress - 从订单中删除商品后订单页面未更新
- html - 在透明 div 之上使子 div 不透明