How do you cancel the writing to a ByteOutputStream in a custom request's getBody method?
Asked Answered
C

0

3

My custom request object is a MultiPartPost Request and has a CountingOutputStream so that I can observe the current upload progress. I am using the custom Request class from this answer : https://mcmap.net/q/89355/-how-to-send-a-multipart-form-data-post-in-android-with-volley

I want to give the user the freedom to cancel it while the upload is ongoing, so it is useful to have the CountingOutputStream, but while I CAN cancel the request (I know as I logged it and the request returns true from its isCancelled() method), the writing to the ByteOutputStream is still ongoing.

Is there a way to cancel it and then like throw aside the call to getBody()?

Cookie answered 3/1, 2016 at 14:28 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.