public Response offlineDownload(@QueryParam("path") String path) {
String plainText = DownloadLocationHelper.decrypt(path);
String[] parts = plainText.split("/");
if (parts.length != 2) {
throw new NotFoundException();
}
String email = parts[0];
String filename = parts[1];
try {
final OfflineDownloadResponse response = downloadResponseFetcher
.fetch(email, filename);
return Response
.ok(new StreamingOutput() {
@Override
public void write(OutputStream output)
throws IOException, WebApplicationException {
IOUtils.copy(response.getBlob().openInputStream(),
output);
}
})
.header("Content-Disposition",
"attachment; filename=" + filename).build();
} catch (IOException e) {
throw new NotFoundException();
}
}