好吧,我得到了一个方法,使其工作。这没有直接的实现。您首先必须导航到该目录并以确切名称检索文件。
/**
* This method will help you retrieve properties of a file or a list of files from particular folder in Azure Blob storage
* @param containerName - Pass the name of the container
* @param path - Location of your file
* @param fileName - You can pass complete file name to retrieve one file or you can pass prefix of the file.
* @return It returns List<BlobProperties> if you pass complete file name, it will return one file or it will find file with supplied prefix.
* @throws Exception
*/
public List<BlobProperties> retriveBlobFilesProperties(String containerName, String path, String fileName) throws Exception{
List<BlobProperties> blobFilesProperties = new ArrayList<BlobProperties>();
CloudStorageAccount cloudStorageAccount = CloudStorageAccount.parse(this.storageConnectionString);
CloudBlobClient cloudBlobClient = cloudStorageAccount.createCloudBlobClient();
CloudBlobContainer cloudBlobContainer = cloudBlobClient.getContainerReference(containerName);
CloudBlobDirectory directory = cloudBlobContainer.getDirectoryReference(path);
Iterable<ListBlobItem> blobItems = directory.listBlobs(fileName);
for(ListBlobItem item : blobItems){
CloudBlob blob = (CloudBlob)item;
blobFilesProperties.add(blob.getProperties());
}
return blobFilesProperties;
}
源:https://softwaretestingboard.com/qna/2197/how-to-download-particular-file-from-azure-blob-using-java
上面的代码将只能得到斑点的属性。我以为你想下载它们。 –
不,我只是想获得blob的属性。谢谢你的指针。 – Mayur
啊,我明白了。从问题标题我想你想下载blob,因此评论:)。 –