Question: Is it possible to send a HTTP request once an upload task finishes?
derwaldgeist opened this issue · 5 comments
Our app can shoot photos and videos, and we want to upload them even if the app is put into background. The files will be uploaded to S3, so there's actually 2 servers involved: S3 and our own server. Once an upload to S3 finishes, we need to signal our own server (via a simple HTTP GET request) that the job is done.
Is it possible to a) receive a callback from the library once a task finishes, and b) does Android allow additional requests in this case? Your docs state that additional uploads in the background are not supported. Does this imply that GET requests are also not possible?
(We've already implemented the same for iOS, and there it is possible to execute another upload task once a task finished. The additional task will just be delayed exponentionally on every new request started in the background.)
You can perform the upload with Upload Service on S3 and use a GlobalRequestObserver calling your own server via a regular OkHttp/Retrofit network call in onSuccess
.
Ok, thank you so much for the fast response. And just to confirm: This OkHttp call will succeed then? I am asking because your docs state that another upload cannot be triggered in the background. So I was wondering if a GET is prevented as well.
In your case you are not uploading anything to your server (if I uderstood correctly), you simply signal it's all good, so it's a regular HTTP request. What I mention in the docs is that you can't perform another file upload while in the background. OkHttp/Retrofit is another set of libraries with their own lifecycle. The ones I recommend for regular network calls on Android. You just trigger the call once the upload is successful.
Ok, thanks for the clarification. Will try it out!
Just as a feedback to other users: This approach worked well. The app is able to send POST requests after an upload finishes, and I am using the GlobalOberver @gotev recommended for this. Awesome.