- // Use buffered array to directly write the stream?
- response.getOutputStream().write(getFileAsByteArray(uri));
- }
-
- /**
- * Retrieves the data as Byte Array given an uri.
- *
- * Overwrite to provide application specific behaviours, like opening from a
- * JCR repository
- */
- protected byte[] getFileAsByteArray(String uri) {
- try {
- if (uri.startsWith(SingleSourcingConstants.FILE_SCHEME)) {
- Path path = Paths.get(getAbsPathFromUri(uri));
- return Files.readAllBytes(path);
- }
- // else if (uri.startsWith(JCR_SCHEME)) {
- // String absPath = Paths.get(getAbsPathFromUri(uri));
- // return Files.readAllBytes(path);
- // }
+ Path path = Paths.get(getAbsPathFromUri(uri));
+ Files.copy(path, response.getOutputStream());