0

I am developing one android app where I need to download a file from the Azure blob I am able to download the file using the following code but I also want to show a progress bar while a file is downloading because it will be a large file say around 1/2 GB.

Gradle dependency:

implementation 'com.microsoft.azure.android:azure-storage-android:2.0.0'

How I am downloading the file:

CloudStorageAccount account = CloudStorageAccount.parse(storageConnectionString);
CloudBlobClient serviceClient = account.createCloudBlobClient();
CloudBlobContainer container = serviceClient.getContainerReference("test");
Iterable blobs = container.listBlobs();
for (Object listBlobItem : blobs) {
     ListBlobItem blob = (ListBlobItem) listBlobItem;
     CloudBlockBlob cloudBlob = (CloudBlockBlob) blob;
     // Downloading files from the container
     cloudBlob.downloadToFile(fileSample.getAbsolutePath());
     Log.e("INFO", "File downloaded");
 }

How can I achieve the download progress?

Harsh Shah
  • 2,162
  • 2
  • 19
  • 39
  • Try to use the `DownloadManager`, here's an example (not mine) : [AzureStorageExplorerAndroid](https://github.com/praneetloke/AzureStorageExplorerAndroid/blob/27306cd75151d4c4508d9d34599600265fcd9e70/app/src/main/java/com/pl/azurestorageexplorer/fragments/BlobListFragment.java) – Mouaad Abdelghafour AITALI Jul 29 '21 at 12:03
  • Ok thanks will check – Harsh Shah Jul 29 '21 at 12:58

1 Answers1

0

The process in the thread1 which gives method to download Blobs by splitting it into small size chunks which is refered in suggestion to this thread2 may give an idea on how to approach .

-Thanks to @Gaurav mantri

Other reference: Asynchronous-parallel-blob-transfers

kavyaS
  • 8,026
  • 1
  • 7
  • 19