一、首先確定NFS已經成功掛載到你的電腦
可以參考:https://blog.csdn.net/fo_xi/article/details/116322816
二、下面演示上傳一個MP4格式視頻
1、工具類
@RequestMapping("/VideoMps4")
@ResponseBody
public Object VideoMps4(@RequestParam MultipartFile file) {
try {
String fileName = file.getOriginalFilename();
if (fileName.equals("TestPush.map")) return "succeed";
//獲取mp4檔案名
String fileJc = fileName.substring(0, fileName.lastIndexOf("."));
//添加檔案名
Long prefix = 10000000L;
//日期檔案名
String foldPath = "/ceshi/" + "2021429" + prefix;
//這里改你掛載的NFS網盤
String dataFold = "D:\\\\web\\\\data\\\\";
//存放路徑
String targetFolderPath = dataFold + foldPath;
File foldFile = new File(targetFolderPath);
//為空建立一個的檔案夾
if (!foldFile.exists()) {
foldFile.mkdirs();
}
//視頻命名
String newFileName = " i like China.mp4";
String filePath = dataFold + foldPath + "/" + newFileName;
File locaFile = new File(filePath);
file.transferTo(locaFile);
return "succeed";
} catch (Exception e) {
e.printStackTrace();
return "error";
}
}
#設定上傳檔案的大小
application.properties配置:spring.http.multipart.maxFileSize = 20MB
三、運行效果,視頻就成功掛載進來了

樓主是用的postman進行測驗的,具體測驗步驟連接:https://blog.csdn.net/fo_xi/article/details/116325569
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/282397.html
標籤:其他
上一篇:2021-4-14C語言練習
