Skip to content

Commit f747c31

Browse files
committed
Adjust the download name when using the API
1 parent ab98ed9 commit f747c31

File tree

2 files changed

+3
-5
lines changed

2 files changed

+3
-5
lines changed

.gitignore

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1 @@
1-
/.idea/Entity-Icons.iml
2-
/.idea/modules.xml
3-
/.idea/vcs.xml
4-
/.idea/workspace.xml
5-
/.idea/misc.xml
1+
/.idea

src/main/java/simplexity/entityicons/ImageController.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,10 @@ public ResponseEntity<byte[]> getImage(@PathVariable String category, @PathVaria
3737
if (resource.exists()) {
3838
try (InputStream inputStream = resource.getInputStream()) {
3939
byte[] imageBytes = StreamUtils.copyToByteArray(inputStream);
40+
String downloadName = filename + "_" + size + "x" + size;
4041
HttpHeaders headers = new HttpHeaders();
4142
headers.add(HttpHeaders.CONTENT_TYPE, "image/png");
43+
headers.add(HttpHeaders.CONTENT_DISPOSITION, String.format("inline; filename=%s", downloadName));
4244

4345
return new ResponseEntity<>(imageBytes, headers, HttpStatus.OK);
4446
} catch (IOException e) {

0 commit comments

Comments
 (0)