Skip to content

Commit 3481170

Browse files
committed
Refactored file upload: generalized HttpGatewayAcceptor file-download
1 parent eb5ccb7 commit 3481170

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

services/src/main/java/io/scalecube/services/files/FileServiceImpl.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -96,17 +96,17 @@ public Flux<ServiceMessage> streamFile() {
9696
.flatMapMany(
9797
context -> {
9898
final var headers = context.headers();
99-
final var name = context.pathVar("name");
100-
final var path = baseDir.resolve(name);
99+
final var filename = context.pathVar("filename");
100+
final var path = baseDir.resolve(filename);
101101

102102
if (!isPathValid(path)) {
103-
return Flux.error(new FileNotFoundException("File not found: " + name));
103+
return Flux.error(new FileNotFoundException("File not found: " + filename));
104104
}
105105

106106
final var message =
107107
ServiceMessage.from(headers)
108108
.header("Content-Type", "application/octet-stream")
109-
.header("Content-Disposition", "attachment; filename=" + name)
109+
.header("Content-Disposition", "attachment; filename=" + filename)
110110
.build();
111111

112112
return Flux.just(message)

services/src/main/java/io/scalecube/services/files/FileStreamer.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,6 @@ public interface FileStreamer {
2121
@Tag(key = "Content-Type", value = "application/file")
2222
@RestMethod("GET")
2323
@ResponseType(byte[].class)
24-
@ServiceMethod("${microservices:id}/files/:name")
24+
@ServiceMethod("${microservices:id}/files/:filename")
2525
Flux<ServiceMessage> streamFile();
2626
}

0 commit comments

Comments
 (0)