Azure blob Java sdk 无法返回对象的 versionID 列表

问题描述

我正在尝试通过 Java SDK 12.10.2 版获取 Azure blob 的 versionID 列表,但它只返回 HTTP 错误 400 并带有以下错误消息

com.azure.storage.blob.models.BlobStorageException: Status code 400,"<?xml version="1.0" encoding="utf-8"?><Error><Code>InvalidQueryParameterValue</Code><Message>Value for one of the query parameters specified in the request URI is invalid.
RequestId:bd7e9a20-401e-003e-6d7b-37d0dd000000
Time:2021-04-22T13:29:12.0965760Z</Message><QueryParameterName>include</QueryParameterName><QueryParameterValue>versions</QueryParameterValue><Reason>Invalid query parameter value.</Reason></Error>"

而且,这是我的 Java 代码:

public static BlobContainerAsyncClient getAzureAsyncClient(String accountName,String accountKey,String endpoint) {
        String connectionString = getConnectionString(accountName,accountKey,endpoint);
        BlobContainerAsyncClient blobServiceClient = new BlobContainerClientBuilder()
          .connectionString(connectionString)
          .serviceVersion(version)
                  .buildAsyncClient();
    RWLog.MAIN.info("Azure Storage Async Service Client created for " + accountName);    
        return blobServiceClient;
}

BlobContainerAsyncClient containerClient = AzureConnection.getAzureAsyncClient(folder.getBucket(),folder.getSecretKey(),folder.getEndpoint());
    ListBlobsOptions ops = new ListBlobsOptions();
    ops.getDetails().setRetrieveVersions(true);
    ops.setPrefix(blobKey);
    PagedFlux<BlobItem> list =
        containerClient.listBlobsByHierarchy("/",ops);

看起来 Azure blob 服务器无法识别 Java SDK 构建的 HTTP 请求。服务器端无法处理来自 Java 客户端的包含版本的查询。 有什么想法吗?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)