in commands/src/main/java/org/jclouds/karaf/commands/blobstore/BlobReadCommand.java [60:83]
protected Object doExecute() throws Exception {
BlobStore blobStore = getBlobStore();
InputStream is = getBlobInputStream(blobStore, containerName, blobName, signedRequest);
try {
if (display) {
CharStreams.copy(new InputStreamReader(is, Charsets.UTF_8), System.out);
System.out.flush();
} else {
if (fileName == null) {
throw new CommandException("Must specify --display or file name");
}
File file = new File(fileName);
if (!file.exists() && !file.createNewFile()) {
throw new IOException("Could not create: " + file);
}
Files.asByteSink(file).writeFrom(is);
}
} finally {
closeQuietly(is);
}
return null;
}