0

I am still spinning up on the Azure Storage Java SDK 10 and its use of reactive programming the paradigm. I wrote the following method to asynchronously download a blob to a byte stream as fast as possible. When I use the synchronous version (below), it works properly. When I comment out the blockingAwait() and uncomment the subscribe, the write and the doOnComplete never are executed... Basically, the run just falls out of the bottom of the method back to the caller. I am sure that I have made an asynchronous processing mistake, and hope that someone can steer me in the correct direction. By the way, I was surprised to find that there are very few samples of downloading to a stream rather than to a file... Hopefully, this posting will help others.

Thank you for your time and interest in my problem...

override fun downloadBlob(url: String, downloadStream: OutputStream) {

    BlockBlobURL(URL(url), pipeline)
            .download(null, null, false, null)
            .flatMapCompletable { response ->
                FlowableUtil.collectBytesInBuffer(response.body(null))
                        .map {
                            Channels.newChannel(downloadStream).write(it)
                        }.toCompletable()
            }.doOnComplete {
                println("The blob was downloaded...")
            }.blockingAwait()
            //.subscribe()
}

Here is the code that is calling the above method:

fun getAerialImageBlobStream(aerialImageUrl: String): MapOutputStream {

    val aerialImageStream = MapOutputStream()
    blobStorage.downloadBlob(aerialImageUrl, aerialImageStream)
    return aerialImageStream
}
A Bit of Help
  • 1,368
  • 19
  • 36
  • How did you create the pipeline? – Tony Ju Apr 11 '19 at 03:46
  • Hi Tony, I've added the method that is requesting to download a blob from Azure to my original posting. I could change it to use a Promise for the download operation, but I am not sure whether this is the best practice when using a Reactive paradigm. I am somewhat of a newbie in the Rx/FRP world... – A Bit of Help Apr 11 '19 at 07:47
  • ... I'd really appreciate any feedback or suggestions... – A Bit of Help Apr 12 '19 at 04:05

0 Answers0