InputStream in1;
Long updatedSize = size;
// prepare URI
BlobURI blobUri = new BlobURI()
.setProfile(profileName)
.setName(blobName);
// encrypt stream
if (encryptionHandler != null)
{
byte[] iv = getCipherIVFromBlobName(blobName);
InputStream encryptedInputStream = this.encryptionHandler.encrypt(in, Configurator.getBlobStoreDefaultEncryptionKey(), iv);
FileBackedOutputStream fbout = new FileBackedOutputStream(MAX_MEMORY_FILE_SIZE, true);
updatedSize = ByteStreams.copy(encryptedInputStream, fbout);
in1 = fbout.getSupplier().getInput();
blobUri.setEncryptionKey(Configurator.getBlobStoreDefaultEncryptionKeyAlias());
} else {
in1 = in;
}
CloudStoreProxy.write(blobName, profileName, in1, updatedSize);