如何使用Azure SDK for Java v12删除单个Blob文件?

huangapple 未分类评论51阅读模式
英文:

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--

huangapple
  • 本文由 发表于 2020年4月9日 19:52:54
  • 转载请务必保留本文链接:https://java.coder-hub.com/61120548.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定