因为框架不同,所以具体实现可能有些许差别,看您的代码思路没问题,不清楚现在具体有什么问题?最快的解决方案是您发您的Demo过来,我们调试下。
下面是我这边Java 接受前端post 过来blob的实现方式,请参考
- @CrossOrigin
- @RequestMapping(value = "/uploadFile", headers = ("content-type=multipart/form-data"), method = RequestMethod.POST)
- public String uploadFile(@RequestParam("file") MultipartFile file,
- @RequestParam("fileName") String fileName) throws FileNotFoundException {
- if (file.isEmpty()) {
- System.out.println("文件空");
- return "上传失败!";
- }
- String filePath = "src/main/resources/reports/" + fileName;
- URL url = ResourceUtils.getURL(filePath);
- System.out.println(filePath);
- File dest = new File(url.getFile());
- try {
- file.transferTo(dest);
- } catch (IOException e) {
- e.printStackTrace();
- }
- return "上传失败!";
- }
复制代码
|