Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/kotlin/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Kotlin SynchronossFormFieldPart无法强制转换为FilePart_Kotlin_Spring Webflux - Fatal编程技术网

Kotlin SynchronossFormFieldPart无法强制转换为FilePart

Kotlin SynchronossFormFieldPart无法强制转换为FilePart,kotlin,spring-webflux,Kotlin,Spring Webflux,我是Spring Webflux的新手,我一直在努力寻找解决问题的方法: 我有一个webclient,它接收一个FilePart并需要将其发布(上载文件)到另一个服务: fun upload(file: Mono<FilePart>): Mono<String> = webClient .post() .uri("/upload") .contentType(MediaType.MULTIPART_FORM_DATA

我是Spring Webflux的新手,我一直在努力寻找解决问题的方法: 我有一个webclient,它接收一个FilePart并需要将其发布(上载文件)到另一个服务:

fun upload(file: Mono<FilePart>): Mono<String> =
    webClient
        .post()
        .uri("/upload")
        .contentType(MediaType.MULTIPART_FORM_DATA)
        .accept(MediaType.TEXT_PLAIN)
        .body(
            BodyInserters.fromMultipartData(
                "file",
                file.flatMapMany(FilePart::content)
            )
        )
        .exchange()
        .flatMap { it.bodyToMono<String>() }
在《邮递员》中,我可以上传文件,但通过我的应用程序,我收到了:

java.lang.ClassCastException: class org.springframework.http.codec.multipart.SynchronossPartHttpMessageReader$SynchronossFormFieldPt cannot be cast to class org.springframework.http.codec.multipart.FilePart
我如何解决这个问题

谢谢

class SomeClass(
    private val part: FilePart
)
java.lang.ClassCastException: class org.springframework.http.codec.multipart.SynchronossPartHttpMessageReader$SynchronossFormFieldPt cannot be cast to class org.springframework.http.codec.multipart.FilePart