Azure存储Blob容器Vituval文件夹图像在JAVA中下载

时间:2020-09-03 16:01:45

标签: java-8 azure-storage azure-blob-storage azure-storage-files azure-java-sdk

我要从具有虚拟文件夹的Azure Storage Blob容器下载映像,它包含映像,需要以Java代码下载该映像。

确保存储结构:

“ Blob容器”->“ Blob文件夹”->“ Sample.jpg”

下面的代码是直接从Container下载图像,我需要从容器内的fodler下载图像

BlobServiceClient storageClient =新的BlobServiceClientBuilder() .endpoint(endpoint.toString()) .credential(凭证) .buildClient();

    BlobContainerClient blobContainer = storageClient.getBlobContainerClient(azureContainer);

    BlockBlobClient blobClient = blobContainer.getBlobClient(fileName).getBlockBlobClient();
    blobClient.download(response.getOutputStream());

1 个答案:

答案 0 :(得分:1)

首先,您需要知道azure blob存储实际上是平坦的存储,实际上根本没有所谓的文件夹。

我的意思是,您必须将路径和文件名组合为文件名传递方法。如果您在当前容器中列出文件,则会发现它们的格式类似于:

folder1/folder2/filename.suffix

相关问题