IndexInput indexInput = null;
try {
indexInput = dir.openInput(fileInfo.physicalName());
indexInput.seek(partNumber * chunkBytes);
InputStreamIndexInput is = new ThreadSafeInputStreamIndexInput(indexInput, chunkBytes);
String blobName = fileInfo.name();
if (fNumberOfChunks > 1) {
// if we do chunks, then all of them are in the form of "[xxx].part[N]".
blobName += ".part" + partNumber;
}
final IndexInput fIndexInput = indexInput;
blobContainer.writeBlob(blobName, is, is.actualSizeToRead(), new ImmutableBlobContainer.WriterListener() {
@Override public void onCompleted() {
try {
fIndexInput.close();
} catch (IOException e) {
// ignore