我是RxJava的新手。我正在从文件API服务接收Flowable对象。
我能够上传单个文件,但我想上传的文件数量与用户选择的数量一样。
我可以使用.zip
并获取结果列表,但是我想使用一个ProgressDialog,该对话框将针对每个上载的文件进行更新。
是否有可能获取每个上传文件的onNext()和onCompleted()回调?
这是我上传单个文件的方式:
final SelectablePhoto photo = currentProduct.getSelectablePhotos().get(i);
Log.d("Uploading", "createFlowableSource:" + photo.getPhotoModel().getPath());
if (photo.getPhotoModel().getPath() != null) {
Config config = new Config(FILE_STACK_API_KEY);
Client client = new Client(config);
String path = photo.getPhotoModel().getPath();
client.uploadAsync(path, true)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(fileLinkProgress -> {
if (fileLinkProgress.getData() != null) {
//file has been uploaded
String pathIn = fileLinkProgress.getData().imageTransform().url();
photo.getPhotoModel().setPath(pathIn);
}
}, throwable -> {
Log.d("error upload", "error uploading file: " + throwable);
uploadDialog.dismiss();
});
谢谢!