Call same retrofit method sequentially for result

2019-09-07 10:52发布

Complete novice with RxJava here. So please bear with me.

I have a Retrofit API which will upload a file. Looks like below

@Multipart
@POST("api")
Observable<ImageUploadResponse> uploadImage(@Part("") MultipartBody.Part body);

Also I have an ArrayList with Uri that I need to upload. When I went through the reactive tutorials, I saw that using "Observable.from" can help me in calling the API sequentially.

Can some one please help me how to read the response from the API every time the API returns a response. My sudo code looks something like below

Observable.from(imageStorageList)
          .map(uri -> new ImageUploadHelper().uploadImage(new File(uri.getPath())))
           .subscribe(imageUploadResponseObservable -> {

                };

I am really not sure how to capture the response inside the subscribe lambda expression. Any help is highly appreciated

0条回答
登录 后发表回答