1

I'm trying to upload a file size of 230GB into azure block blob with the following code

private void uploadFile(FileObject srcFile, FileObject destFile) throws Exception {

    try {
        
        BlobClient destBlobClient = blobContainerClient.getBlobClient("destFilename");

        long blockSize = 4 * 1024 * 1024 // 4 MB

       
        ParallelTransferOptions opts = new ParallelTransferOptions()
                .setBlockSizeLong(blockSize)
                .setMaxConcurrency(5);

        BlobRequestConditions requestConditions = new BlobRequestConditions();

        try (BlobOutputStream bos = destBlobClient.getBlockBlobClient().getBlobOutputStream(
                opts, null, null, null, requestConditions);

                InputStream is = srcFile.getContent().getInputStream()) {

            byte[] buffer = new byte[(int) blockSize];
            int i = 0;
            for (int len; (len = is.read(buffer)) != -1; ) {
                bos.write(buffer, 0, len);
            }

        }

    }
    finally {
        destFile.close();
        srcFile.close();
    }
}

Since,I am explicitly setting block size 4MB for each write operation I'm in a assumption that each write block is considered as single block in azure. But which is not the case.

For the above example 230GB file the write operation was executed 58880 times and the file got uploaded successfully.

Can someone please explain me more about how blocks are splits internally in azure and let help me to understand better.

Thanks in advance

Krishnan
  • 185
  • 3
  • 11

0 Answers0