谁能指导我如何在Java SDK中模拟azure Blob存储?
我想模拟连接字符串,SAS令牌,端点,containerName。如果所有这些都被模拟,那么模拟BlobClient就很容易了。
参考代码为-public BlobServiceClient BlobServiceClient (){返回新的BlobServiceClientBuilder().connectionString("测试字符串").buildClient();}
要解决此问题,您可以在同一项目下的文件中使用各自的变量保留连接字符串,SAS令牌,端点,ContainerName的值。您可以使用下面的语句通过在代码中传递上述对象来模拟blobClient。
BlobClient blobClient = new BlobClientBuilder()
.endpoint("<your-storage-account-url>")
.sasToken("<your-sasToken>")
.containerName("mycontainer")
.blobName("myblob")
.buildClient();
或
// Only one "?" is needed here. If the sastoken starts with "?", please removing one "?".
BlobClient blobClient = new BlobClientBuilder()
.endpoint("<your-storage-account-url>" + "/" + "mycontainer" + "/" + "myblob" + "?" + "<your-sasToken>")
.buildClient();
参考:https://learn.microsoft.com/en-us/java/api/overview/azure/storage-blob-readme?view=azure-java-stable