Skip to content

Instantly share code, notes, and snippets.

@pryorda
Created February 5, 2017 18:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pryorda/14a18e9ecbd302af73903cd4e37c1e0b to your computer and use it in GitHub Desktop.
Save pryorda/14a18e9ecbd302af73903cd4e37c1e0b to your computer and use it in GitHub Desktop.
ubuntu@dsapi-0:/mnt/fsstore/LOGO/3b/38e/092/374/b44/7cb$ ls
3b38e092-374b-447c-b208-f807be406bd4
ubuntu@dsapi-0:/mnt/fsstore/LOGO/3b/38e/092/374/b44/7cb$ ls
private static int writeData(File storageRoot, Entity entity, String uuid, InputStream inputStream) throws IOException {
Preconditions.checkNotNull(inputStream);
File file = getDataFile(storageRoot, entity, uuid);
file.getParentFile().mkdirs();
FileOutputStream fos = null;
try {
logger.debug("Writing data to {}", file.getAbsolutePath());
fos = new FileOutputStream(file);
byte[] inputStreamBytes = IOUtils.toByteArray(inputStream);
fos.write( inputStreamBytes, 0, inputStreamBytes.length );
return inputStreamBytes.length / 1024 ;
} finally {
IOUtils.closeQuietly(fos);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment