How to make progress for multi-user upload of multiple files using OkHTTP3 / Retrofit2?

I load a dynamic number of files into a single multi-page request using Retrofit2. My modified interface looks like this:

public interface FileUploadService { @Multipart @POST("upload") Call<ResponseBody> uploadMultipleFilesDynamic( @Part List<MultipartBody.Part> files); } 

Now I want to track the progress of this multi-file download. This solution explains how to make progress when loading a single file in a multi-page request by expanding RequestBody . Although I can’t figure out how to apply this to my request for multiple files. One solution that I thought of was to create a ProgressRequestBody by extending the OkHTTP MultipartBody class instead of RequestBody , but OkHTTP3 implements MultipartBody as the final class, making it impossible to extend it. Can someone point me in the right direction, since this is a huge blocker so that I can not show the progress to the user to upload files. Or is there any work that I can implement to achieve this functionality?

+5
source share

Source: https://habr.com/ru/post/1269679/


All Articles