Replies: 2 comments 5 replies
-
Is it about sending the data to the server or about reading from the server? If you want upload data from a stream, you can generate the Would that be an option? Otherwise yes maybe async methods (I'd also like to have them, but okhttp is still in alpha for that), or an optional parameter that allows getting the response without closing? But if it's only for uploading, that shouldn't be needed. And for streamed downloading, this is normally done with GET (which you can control yourself anyway) or in small in-line packages (like in |
Beta Was this translation helpful? Give feedback.
-
Thanks for the quick response!
It is about both. In simplified terms: For backup I need to send data, for restore I need to read data.
Thanks, this looks similar to the stream recipe in the okhttp documentation. I actually also have a If you are interested, here's the API and here how they implemented it. So I don't really see a way how this would work with inheriting
Oh I haven't seen this. It looked like I had to read from the response body stream before the callback terminates. Or are you suggesting to make my own GET requests with okhttp and not using the library? I haven't looked into the restore use-case in detail, but a cursory look suggests that it may be more feasible to do inside a callback (only that I'd have to refactor my entire plugin API and the code that uses it). So getting the response body stream and being allowed to close it myself when done would be helpful I think. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I was hoping to use this library for a native WebDAV connection for the Seedvault backup app. However, after digging more into it, I noticed that all requests made via
DavCollection
are using a callback and that the okhttpResponse
gets auto-closed after the callback was invoked.This is really bad for using these requests in an existing complicated codebase, because all stream operations (reading/writing) have to happen inside this callback. A more flexible approach would be to give the API user access to the streams/sinks and don't auto-close them.
To illustrate where I am coming from: The Android back API is calling my code repeatedly to give me bytes of app's backup data in small chunks. I have no control over how I am called, but I need to write the bytes away for safe-keeping. So there's no way of doing this inside a callback of an dav4jvm request. If I'd simply get an
OutputStream
from the library, I could keep writing to it until I am done and then close it.So I could probably use
suspendCoroutine()
to work around the callback, but then the auto-closing is really breaking my neck here.Is it imaginable that this library accommodates my use-case in a not too far away future? This may or may not be related to #2
Beta Was this translation helpful? Give feedback.
All reactions