3 回答

TA貢獻(xiàn)1871條經(jīng)驗(yàn) 獲得超13個(gè)贊
listBlobs()
方法有一個(gè)overload
接受prefix
參數(shù)。
public?Iterable<ListBlobItem>?listBlobs(final?String?prefix,?final?boolean?useFlatBlobListing)?{ ????????return?this.listBlobs(prefix,?useFlatBlobListing,?EnumSet.noneOf(BlobListingDetails.class),?null,?null); ????}
您需要傳遞path of the folder
asprefix
和傳遞true
for?useFlatBlobListing
,這將列出該虛擬文件夾中的所有 blob。
獲得該 blob 列表后,您可以使用downloadToFile
每個(gè) blob 上的方法下載 blob。

TA貢獻(xiàn)1943條經(jīng)驗(yàn) 獲得超7個(gè)贊
一段時(shí)間后,我發(fā)現(xiàn)我可以應(yīng)用CloudBlockBlob類(lèi)型ListBlobItem和下載方法。
@Bean
@SneakyThrows
public CommandLineRunner commandLineRunner(CloudBlobContainer blobContainer) {
return args -> {
Sets.newConcurrentHashSet(blobContainer.listBlobs("documents/"))
.stream()
.filter(it -> it.getUri().toString().contains("pdf"))
.forEach(it -> {
((CloudBlockBlob) it).downloadToFile(((CloudBlockBlob) it).getName());
});
};
}

TA貢獻(xiàn)1797條經(jīng)驗(yàn) 獲得超6個(gè)贊
你可以通過(guò)兩種方式做到這一點(diǎn)
(i) AZcopy-AzCopy /Source:https://myaccount.file.core.windows.net/demo/ /Dest:C:\myfolder /SourceKey:key /S
(ii) 通過(guò)Azure Cli——
# Create a directory to store all the blobs
mkdir /downloaded-container && cd /downloaded-container
# Get all the blobs
BLOBS=$(az storage blob list -c $CONTAINER \
? ? --account-name $ACCOUNT_NAME --sas-token "$SAS_TOKEN" \
? ? --query [*].name --output tsv)
# Download each one
for BLOB in $BLOBS
do
? echo "********Downloading $BLOB"
? az storage blob download -n $BLOB -f $BLOB -c $CONTAINER --account-name $ACCOUNT_NAME --sas-token "$SAS_TOKEN"
done
如果您只想通過(guò)代碼,這里有一個(gè),sample repo
因?yàn)闆](méi)有直接的方法可以通過(guò) SDK 完成。
HttpGet httpGet = new HttpGet(urlString);
? ? ? ? ? ? signRequest(httpGet, resourcePath, account, hashFunction);
? ? ? ? ? ? try (CloseableHttpResponse response = httpClient.execute(httpGet)) {
? ? ? ? ? ? ? ? System.out.println(response.getStatusLine());
添加回答
舉報(bào)