spring-framework icon indicating copy to clipboard operation
spring-framework copied to clipboard

FilePart transferTo method can't write file to destPath

Open mrtr9 opened this issue 3 years ago • 0 comments

Spring Framework Version:5.3.22 Spring Boot Version:2.7.3

` import org.springframework.http.codec.multipart.FilePart; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RestController; import reactor.core.publisher.Mono;

import java.io.File;

@RestController public class TestController {

@PostMapping("test")
public Mono<R> test(FilePart file){
    String fileName = file.filename();
    File newFile = new File("F:/images/banner/",fileName);
    file.transferTo(newFile);
    return Mono.just(R.ok());
}

} `

i upload an jpg and use transferTo method to write file to the path.but i can't found the picture in the F:/images/banner/

mrtr9 avatar Sep 22 '22 06:09 mrtr9