英文:
How to delete a single Blob file with Azure SDK for Java v12?
问题
以下是翻译好的部分:
如何使用Azure SDK v12 for Java删除单个Blob文件?
这是我到目前为止尝试过的方法,但不起作用。
顺便提一下,示例代码是Kotlin:
val blobServiceClient: BlobServiceAsyncClient by lazy {
BlobServiceClientBuilder()
.endpoint(blobProperties.endpoint)
.sasToken(blobProperties.sasToken)
.buildAsyncClient()
}
val containerClient = blobServiceClient.getBlobContainerAsyncClient(blobProperties.containerName)
val blobName = "test.jpg"
val imageClient = containerClient.getBlobAsyncClient(blobName).blockBlobAsyncClient
val deleteImage = imageClient.delete()
println(deleteImage)
我们使用的库是"azure-storage-blob-12.4.0.jar"。
英文:
How do you delete a single Blob file with the Azure SDK v12 for Java?
This is what i tried so far. But it doesn't work.
Btw the sample code is Kotlin:
val blobServiceClient: BlobServiceAsyncClient by lazy {
BlobServiceClientBuilder()
.endpoint(blobProperties.endpoint)
.sasToken(blobProperties.sasToken)
.buildAsyncClient()
}
val containerClient = blobServiceClient.getBlobContainerAsyncClient(blobProperties.containerName)
val blobName = "test.jpg"
val imageClient = containerClient.getBlobAsyncClient(blobName).blockBlobAsyncClient
val deleteImage = imageClient.delete()
println(deleteImage)
We are using the library "azure-storage-blob-12.4.0.jar"
答案1
得分: 0
最终,一个简单的 block()
对我有效,它使得 MonoFlatMap 无限期地阻塞,直到接收到下一个信号。
containerClient.getBlobAsyncClient(blobName).delete().block()
如果您想进一步了解关于 block()
的信息,您可以在这里找到:
https://projectreactor.io/docs/core/release/api/reactor/core/publisher/Mono.html#block--
英文:
In the end a simple block()
was what worked for me which causes the MonoFlatMap to block indefinitely until a next signal is received.
containerClient.getBlobAsyncClient(blobName).delete().block()
If you want to read further information about block() you can find it here:
https://projectreactor.io/docs/core/release/api/reactor/core/publisher/Mono.html#block--
专注分享java语言的经验与见解,让所有开发者获益!
评论