'Download File with Micronaut
My Client should receive a File from the Controller. The problem is that the Client is only receiving a string. How can I get the returned stream from the Controller?
This is my Controller:
@Get("/{databaseName}")
MutableHttpResponse < Object > createDatabaseBackup(String databaseName) {
InputStream inputStreamDatabaseBackup = backupTask.exportBackup(databaseName);
return HttpResponse.ok(new StreamedFile(inputStreamDatabaseBackup, MediaType.APPLICATION_OCTET_STREAM_TYPE));
}
Here is my Client:
@Inject
@Client("${agent.connection-url}")
private RxHttpClient client;
public String getBackup(String dataBaseName) {
return client.toBlocking().retrieve(HttpRequest.GET("/backup/" + dataBaseName));
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
