Feature
Provide a way, such that while uploading or downloading any media( files, images, videos ) content to/from the server we can show the percentage progress of that operation.
I think it's belong to the HTTP Client that you use with Retrofit. If you are using OkHttp3, firstly you have to create a wrapper of RequestBody that inform to you the progress while executing. After that, create a wrapper RequestBody from the file you intend to upload.
The example of ProgressRequestBody can be found here and the sample request can be found here
Don't you think it's a lot of boilerplate, which I'll have to write every time my project needs a percentage progress feature? Not to mention the issues related to it( which can be found in the comments of the same SO question). Life would be much more easy if some easy API provided this feature.
+1
Retrofit is a library for making API calls on the background thread and is already doing a lot of the work for us. Getting percentage of a file upload is not part of features related to this library. There are many tutorials that use RXjava to calculate how much of the file size is uploaded already. It took me less than half a day to make my own without any prior knowledge. You can create your own utility and reuse it instead of writing boiler plate each time.
Retrofit is a library for making API calls on the background thread and is already doing a lot of the work for us. Getting percentage of a file upload is not part of features related to this library.
Why not? Upload and download progress are essential information, because neither is an atomic operation.
There are many tutorials that use RXjava to calculate how much of the file size is uploaded already.
There is a lot of bad and outdated code on stackoverflow, where people copy and paste from.
It took me less than half a day to make my own without any prior knowledge. You can create your own utility and reuse it instead of writing boiler plate each time.
_Less than half a day_ is pretty much for this basic feature. We could save a lot of accumulated work time, if not everyone is forced to write his/her own utility but have it right in the library.
Retrofit is a library for making API calls on the background thread and is already doing a lot of the work for us. Getting percentage of a file upload is not part of features related to this library.
Why not? Upload and download progress are essential information, because neither is an atomic operation.
There are many tutorials that use RXjava to calculate how much of the file size is uploaded already.
There is a lot of bad and outdated code on stackoverflow, where people copy and paste from.
It took me less than half a day to make my own without any prior knowledge. You can create your own utility and reuse it instead of writing boiler plate each time.
_Less than half a day_ is pretty much for this basic feature. We could save a lot of accumulated work time, if not everyone is forced to write his/her own utility but have it right in the library.
Firstly as I said it's a library for making API calls and parsing the information. What you require is a feature outside the range of the library.
Sure there are bad and outdated codes and it's up to you to research and learn the technique and come up with an updated version preferably using flowable and rxjava to do the percentage calculation. After all you are the developer.
Your expectation is like buying a stove and expecting it to tell you if you are overcooking your food.
Try making API calls without retrofit using the old fashion way and you learn to appreciate how much it's doing already.
Firstly as I said it's a library for making API calls and parsing the information. What you require is a feature outside the range of the library.
Progress reporting is an essential feature for APIs that transfer larger amounts of data. Where can you find a statement, that this is outside the scope of this library?
Sure there are bad and outdated codes and it's up to you to research and learn the technique and come up with an updated version preferably using flowable and rxjava to do the percentage calculation. After all you are the developer.
Minimizing the possibility of API misuse is an important quality consideration when choosing a library. All the Square libraries I used are clearly designed with this in mind.
Your expectation is like buying a stove and expecting it to tell you if you are overcooking your food.
It would be more like buying a stove and and discovering that it can only do off or maximum power.
Try making API calls without retrofit using the old fashion way and you learn to appreciate how much it's doing already.
I did that, how is that supposed to be an argument?
Look, I do not want to take this silly discussion any further. If this is in the scope of the library is for the maintainers to decide, neither me, nor you. But please do not tell other people, what is in scope or not, as long as you are not a maintainer or have a definite statement about this matter to reference. This is really not helpful and might even detract possible contributors.
Firstly as I said it's a library for making API calls and parsing the information. What you require is a feature outside the range of the library.
Progress reporting is an essential feature for APIs that transfer larger amounts of data. Where can you find a statement, that this is outside the scope of this library?
Sure there are bad and outdated codes and it's up to you to research and learn the technique and come up with an updated version preferably using flowable and rxjava to do the percentage calculation. After all you are the developer.
Minimizing the possibility of API misuse is an important quality consideration when choosing a library. All the Square libraries I used are clearly designed with this in mind.
Your expectation is like buying a stove and expecting it to tell you if you are overcooking your food.
It would be more like buying a stove and and discovering that it can only do off or maximum power.
Try making API calls without retrofit using the old fashion way and you learn to appreciate how much it's doing already.
I did that, how is that supposed to be an argument?
Look, I do not want to take this silly discussion any further. If this is in the scope of the library is for the maintainers to decide, neither me, nor you. But please do not tell other people, what is in scope or not, as long as you are not a maintainer or have a definite statement about this matter to reference. This is really not helpful and might even detract possible contributors.
In all the time you spent arguing with me and asking others to add a feature you deem necessary you could have built it your self and better yet make a PR for it to be added to retrofit.
I never said this is not in the scope, I merely said the library can not include everything. API calls are very broad. It can return JSON or XML or even Bindary or god knows what else. There could be various methods of making the connection with various protocols.
The point is all of this is big enough for one library to include and the more features added to more bugs it can introduce. Hence why Retrofit is one library and it welcomes others like GSON, OKHTTP and even Stetho to work as interceptors and converters.
If you are still looking for a good way to do it let me know and ill send you a snippet of how I did it to hopefully help you out.
If you are still looking for a good way to do it let me know and ill send you a snippet of how I did it to hopefully help you out.
@20ali20 please share your ideas
I used this article when I first needed such thing and then modified it to my needs :
https://medium.com/@PaulinaSadowska/display-progress-of-multipart-request-with-retrofit-and-rxjava-23a4a779e6ba
she has great explanation.
But basically short story here is the summary of what happens :
Also many server utilities already offer a library for it. For Example AWS S3 Bucket has its own uploading tool which is nice and offers percentage update and much more as well as pause and upload later feature.
Interesting article. One last thing, any ideas how can we achieve the same feature without Rx. My peers prefer Kotlin Coroutines, so any solution which embraces coroutines would really help.
All the Rx does is making the updater/listener.
Not sure how well Coroutines work with them being used as an observer as they are relatively new and not fully supported.
Another option is something like Event Bus which is used if you want to have a source of truth and whatever registers to it to get updates of its changes.
Most helpful comment
Don't you think it's a lot of boilerplate, which I'll have to write every time my project needs a percentage progress feature? Not to mention the issues related to it( which can be found in the comments of the same SO question). Life would be much more easy if some easy API provided this feature.