in urlhandler/src/main/java/org/jclouds/karaf/urlhandler/BlobUrlHandler.java [158:195]
public OutputStream getOutputStream() throws IOException {
try {
final BlobStore blobStore = ServiceHelper.getService(id, providerOrApi, blobStores);
if (!blobStore.containerExists(containerName)) {
blobStore.createContainerInLocation(null, containerName);
}
final CountDownLatch readLatch = new CountDownLatch(1);
final File tmpDir = Files.createTempDir();
final File tmpBlob = File.createTempFile("blob", null, tmpDir);
FileOutputStream out = new FileOutputStream(tmpBlob) {
@Override
public void close() throws IOException {
readLatch.countDown();
}
};
Runnable putBlob = new Runnable() {
@Override
public void run() {
try {
readLatch.await();
Blob blob = blobStore.blobBuilder(blobName).payload(tmpBlob).build();
blobStore.putBlob(containerName, blob);
tmpBlob.delete();
tmpDir.delete();
} catch (InterruptedException e) {
logger.error("Interrupted while waiting on blob read.", e);
}
}
};
executorService.submit(putBlob);
return out;
} catch (Exception e) {
throw (IOException) new IOException("Error opening blob protocol url").initCause(e);
}
}