我是 RxJava 编码语言的新手。
我正在尝试编写一个函数,以递归方式从一个 S3 位置复制文件并将内容粘贴到另一个 S3 位置。
这是我为此编写的代码
private Single<CopyObjectResponse> copyObjectsRecursively(String sourceBucketName, String sourceKeyPrefix,String destinationBucketName, String destinationKeyPrefix) {
return listObjects(sourceKeyPrefix, sourceBucketName)
.concatMap(listObjectsV2Response -> Observable.fromIterable(listObjectsV2Response.contents())
.flatMapSingle(s3Object -> {
if (s3Object.key().endsWith("/")) {
String newSourceKey = s3Object.key();
String newDestinationKey = buildDestinationKey(destinationKeyPrefix, newSourceKey, sourceKeyPrefix);
return copyObjectsRecursively(sourceBucketName, newSourceKey, destinationBucketName, newDestinationKey);
} else {
CopyObjectRequest copyRequest = CopyObjectRequest.builder()
.sourceBucket(sourceBucketName)
.sourceKey(s3Object.key())
.destinationBucket(destinationBucketName)
.destinationKey(buildDestinationKey(destinationKeyPrefix, s3Object.key(), sourceKeyPrefix))
.build();
return Single.fromFuture(buildClient.copyObject(copyRequest));
}
}))
.ignoreElements()
.toSingleDefault(null)
.onErrorResumeNext(error -> Single.error(error));
}
这段代码的问题是,这是在抱怨
cannot find symbol
[ERROR] symbol: method concatMap((listObjec[...] } }))
[ERROR] location: class io.reactivex.Single<software.amazon.awssdk.services.s3.model.ListObjectsV2Response>
我已经检查我的代码中是否有正确的导入
import io.reactivex.Single;
import io.reactivex.Completable;
import io.reactivex.Observable;
但这还是在抱怨
我尝试查看代码中的所有导入,检查了 RxJava(2.x.x) 的版本,但仍然无法在代码中找到 concatMap 符号。