If you want to download a file from a Azure container, you can easily do it by using azure API's. The correct way to download a file from azure container is to first ensure that the container is present or not.
So if you want to check that the container is available or not, please check this post.
public static void downloadFiles(String containerName) {
BlobServiceClient blobServiceClient = createBlobServiceClient();
BlobContainerClient containerClient = blobServiceClient.getBlobContainerClient(containerName);
for (BlobItem blobItem : containerClient.listBlobs()) {
BlobClient blobClient = containerClient.getBlobClient(blobItem.getName());
File downloadedFile = new File(downloadedPath + blobItem.getName());
System.out.println("\nDownloading blob to\n\t " + downloadedFile);
blobClient.downloadToFile(downloadedFile.getPath());
}
}
where the downloadedPath is your local path from where you want to store the file.
static String downloadedPath = "data\\downloaded\\";
Once the file is downloaded, you can read the content from it also.
No comments:
Post a Comment