Search code examples
c#azureazure-storageazure-blob-storage

Download partial file from Azure storage


I have files which are big in size. Since the file size is too large, I have been trying to download partial file from Azure blob storage. I have been using DownloadRangeToStream method from class CloudBlockBlob and it works perfectly fine for me.

Now we are planning to use Azure.Storage.Blobs.Specialized.BlockBlobClient for upload and there is not similar method in BlockBlobClient class which download file in range or blob block (Not the whole file but a block of it)

I was wondering if there is any other way to do the same in more optimized way.!!


Solution

  • The method you would want to use is Download(HttpRange, BlobRequestConditions, Boolean, CancellationToken) which is in BlobBaseClient class (BlockBlobClient derives from this class).

    HttpRange parameter of this method is where you would define the offset and length.