Przeglądaj źródła

视频上传修正

亨利王 1 rok temu
rodzic
commit
6bdbfc1bb8

+ 1 - 1
.idea/misc.xml

@@ -9,7 +9,7 @@
     </option>
     <option name="workspaceImportForciblyTurnedOn" value="true" />
   </component>
-  <component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" project-jdk-name="1.8.0_102" project-jdk-type="JavaSDK">
+  <component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" project-jdk-name="1.8" project-jdk-type="JavaSDK">
     <output url="file://$PROJECT_DIR$/out" />
   </component>
 </project>

Plik diff jest za duży
+ 0 - 3
.idea/shelf/Uncommitted_changes_before_Update_at_2024_2_22_10_24_[Changes]/shelved.patch


+ 0 - 4
.idea/shelf/Uncommitted_changes_before_Update_at_2024_2_22_10_24__Changes_.xml

@@ -1,4 +0,0 @@
-<changelist name="Uncommitted_changes_before_Update_at_2024_2_22_10_24_[Changes]" date="1708568725460" recycled="true" deleted="true">
-  <option name="PATH" value="$PROJECT_DIR$/.idea/shelf/Uncommitted_changes_before_Update_at_2024_2_22_10_24_[Changes]/shelved.patch" />
-  <option name="DESCRIPTION" value="Uncommitted changes before Update at 2024/2/22 10:24 [Changes]" />
-</changelist>

Plik diff jest za duży
+ 0 - 3
.idea/shelf/Uncommitted_changes_before_Update_at_2024_2_26_19_11_[Changes]/shelved.patch


+ 0 - 4
.idea/shelf/Uncommitted_changes_before_Update_at_2024_2_26_19_11__Changes_.xml

@@ -1,4 +0,0 @@
-<changelist name="Uncommitted_changes_before_Update_at_2024_2_26_19_11_[Changes]" date="1708945905653" recycled="true" deleted="true">
-  <option name="PATH" value="$PROJECT_DIR$/.idea/shelf/Uncommitted_changes_before_Update_at_2024_2_26_19_11_[Changes]/shelved.patch" />
-  <option name="DESCRIPTION" value="Uncommitted changes before Update at 2024/2/26 19:11 [Changes]" />
-</changelist>

+ 14 - 7
.idea/workspace.xml

@@ -5,8 +5,14 @@
   </component>
   <component name="ChangeListManager">
     <list default="true" id="46b159bd-08ca-42f0-b80f-41d4944a8a29" name="Changes" comment="使用手册模块更新">
+      <change beforePath="$PROJECT_DIR$/.idea/misc.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/misc.xml" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/.idea/shelf/Uncommitted_changes_before_Update_at_2024_2_22_10_24_[Changes]/shelved.patch" beforeDir="false" />
+      <change beforePath="$PROJECT_DIR$/.idea/shelf/Uncommitted_changes_before_Update_at_2024_2_22_10_24__Changes_.xml" beforeDir="false" />
+      <change beforePath="$PROJECT_DIR$/.idea/shelf/Uncommitted_changes_before_Update_at_2024_2_26_19_11_[Changes]/shelved.patch" beforeDir="false" />
+      <change beforePath="$PROJECT_DIR$/.idea/shelf/Uncommitted_changes_before_Update_at_2024_2_26_19_11__Changes_.xml" beforeDir="false" />
       <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
-      <change beforePath="$PROJECT_DIR$/README.md" beforeDir="false" afterPath="$PROJECT_DIR$/README.md" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/src/main/java/com/om/controller/admin/UtilController.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/om/controller/admin/UtilController.java" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/src/main/resources/application-dev.yml" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/resources/application-dev.yml" afterDir="false" />
     </list>
     <option name="SHOW_DIALOG" value="false" />
     <option name="HIGHLIGHT_CONFLICTS" value="true" />
@@ -67,16 +73,17 @@
     &quot;SHARE_PROJECT_CONFIGURATION_FILES&quot;: &quot;true&quot;,
     &quot;Spring Boot.OperationApplication.executor&quot;: &quot;Run&quot;,
     &quot;WebServerToolWindowFactoryState&quot;: &quot;false&quot;,
-    &quot;git-widget-placeholder&quot;: &quot;permission-wxy&quot;,
+    &quot;git-widget-placeholder&quot;: &quot;master&quot;,
+    &quot;ignore.virus.scanning.warn.message&quot;: &quot;true&quot;,
     &quot;kotlin-language-version-configured&quot;: &quot;true&quot;,
-    &quot;last_opened_file_path&quot;: &quot;/Users/wangwulin/IdeaProjects/OperationSystem/src/main/resources/mapper&quot;,
+    &quot;last_opened_file_path&quot;: &quot;C:/Users/thomas/IdeaProjects/OperationSystem/pom.xml&quot;,
     &quot;node.js.detected.package.eslint&quot;: &quot;true&quot;,
     &quot;node.js.detected.package.tslint&quot;: &quot;true&quot;,
     &quot;node.js.selected.package.eslint&quot;: &quot;(autodetect)&quot;,
     &quot;node.js.selected.package.tslint&quot;: &quot;(autodetect)&quot;,
     &quot;nodejs_package_manager_path&quot;: &quot;npm&quot;,
     &quot;npm.dev.executor&quot;: &quot;Run&quot;,
-    &quot;project.structure.last.edited&quot;: &quot;Project&quot;,
+    &quot;project.structure.last.edited&quot;: &quot;&quot;,
     &quot;project.structure.proportion&quot;: &quot;0.15&quot;,
     &quot;project.structure.side.proportion&quot;: &quot;0.2&quot;,
     &quot;settings.editor.selected.configurable&quot;: &quot;MavenSettings&quot;,
@@ -146,7 +153,6 @@
     <recent_temporary>
       <list>
         <item itemvalue="Spring Boot.OperationApplication" />
-        <item itemvalue="Application.CodeGenerator" />
         <item itemvalue="npm.dev" />
         <item itemvalue="Spring Boot.OperationApplication" />
         <item itemvalue="npm.dev" />
@@ -156,8 +162,7 @@
   <component name="SharedIndexes">
     <attachedChunks>
       <set>
-        <option value="jdk-1.8.0_392-corretto-1.8.0_392-4caba194b151-3820a516" />
-        <option value="jdk-20.0.2-corretto-20.0.2.1-4caba194b151-d89c1816" />
+        <option value="jdk-1.8.0_402-corretto-1.8.0_402-3183f394aec4-734fdc6e" />
       </set>
     </attachedChunks>
   </component>
@@ -203,6 +208,8 @@
       <workItem from="1708925853376" duration="15000000" />
       <workItem from="1709043200200" duration="1433000" />
       <workItem from="1709105595721" duration="585000" />
+      <workItem from="1709597538938" duration="1349000" />
+      <workItem from="1709599670703" duration="2260000" />
     </task>
     <task id="LOCAL-00001" summary="管理员登录">
       <option name="closed" value="true" />

+ 53 - 2
src/main/java/com/om/controller/admin/UtilController.java

@@ -51,11 +51,62 @@ public class UtilController {
         }
     }
 
+    @ApiOperation("图片上传接口")
+    @PostMapping("/photo")
+    public Result photo(@RequestParam("file") MultipartFile file,
+                        HttpServletRequest request,
+                        @RequestParam("id") Integer id) {
+        MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
+        MultipartFile headerImage = multipartRequest.getFile("file");
+        String fileName = headerImage.getOriginalFilename();
+
+        //根据当前时间生成文件名
+        fileName = new SimpleDateFormat("yyyy-MM-dd-HH-mm-ss").format(new Date()) + "." + fileName;
+        // 确定文件存放的路径
+        File dest = new File(fileUploadPath + fileName);
+        //判断当前目录是否存在
+        if (!dest.exists()) {
+            //目录不存在,需要创建
+            dest.mkdir();
+        }
+        try {
+            // 存储文件
+            headerImage.transferTo(dest);
+        } catch (IOException e) {
+            throw new RuntimeException("上传文件失败,服务器发生异常!", e);
+        }
+
+        System.out.println("文件名:" + fileName);
+
+        return Result.succ(fileName);
+    }
+
+    @ApiOperation("视频下载接口")
+    @GetMapping("/downloadv")
+    public void downloadv(String name, HttpServletResponse response) {
+        try {
+            //输入流,通过输入流读取文件内容
+            FileInputStream fileInputStream = new FileInputStream(fileUploadPath  + name);
+            //输出流,通过输出流将文件写回浏览器,在浏览器展示图片
+            ServletOutputStream outputStream = response.getOutputStream();
+            response.setContentType("video/mp4");
+            int len;
+            byte[] bytes = new byte[4096];
+            while ((len = fileInputStream.read(bytes)) != -1) {
+                outputStream.write(bytes, 0, len);
+            }
+            outputStream.close();
+            fileInputStream.close();
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+    }
+
     @ApiOperation("视频上传接口")
     @PostMapping("/video")
     public Result video(@RequestParam("file") MultipartFile file,
-                              HttpServletRequest request,
-                              @RequestParam("id") Integer id) {
+                        HttpServletRequest request,
+                        @RequestParam("id") Integer id) {
         MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
         MultipartFile headerImage = multipartRequest.getFile("file");
         String fileName = headerImage.getOriginalFilename();

+ 6 - 3
src/main/resources/application-dev.yml

@@ -25,7 +25,10 @@ spring:
   mvc:
     pathmatch:
       matching-strategy: ant_path_matcher
-
+  servlet:
+    multipart:
+      max-file-size: 50MB
+      max-request-size: 50MB
 #jwt配置
 #密钥
 jwt:
@@ -35,8 +38,8 @@ jwt:
 # 手册视频上传路径
 files:
   upload:
-    path: /Users/wangwulin/Desktop/
-#    path: C:/temp/FaceInfo/
+#    path: /Users/wangwulin/Desktop/
+    path: C:/temp/
 
 # 照片存放路径
 photo:

Niektóre pliki nie zostały wyświetlone z powodu dużej ilości zmienionych plików