简体   繁体   中英

How to delete a single Blob file with Azure SDK for Java v12?

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"

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM