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

问题描述

我要从具有虚拟文件夹的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());

解决方法

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

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

folder1/folder2/filename.suffix

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...