编写spring boot fileupload 样例
时间: 2023-03-14 10:30:13 浏览: 144
Spring boot实现文件上传实例(多文件上传)
我可以提供一些有关Spring Boot文件上传的实例代码,例如:@RestController
public class FileUploadController {
@PostMapping("/upload")
public ResponseEntity<Object> uploadFile(@RequestParam("file") MultipartFile file) throws IOException {
File convertFile = new File("/Users/upload/"+file.getOriginalFilename());
convertFile.createNewFile();
FileOutputStream fout = new FileOutputStream(convertFile);
fout.write(file.getBytes());
fout.close();
return new ResponseEntity<>("File is uploaded successfully", HttpStatus.OK);
}
}
阅读全文