spring-framework
spring-framework copied to clipboard
FilePart transferTo method can't write file to destPath
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/