You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
45 lines
1.4 KiB
Java
45 lines
1.4 KiB
Java
package com.superversion.rasa.controller;
|
|
|
|
|
|
import io.swagger.annotations.Api;
|
|
import io.swagger.annotations.ApiOperation;
|
|
import lombok.RequiredArgsConstructor;
|
|
import org.springframework.web.bind.annotation.*;
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
import java.io.File;
|
|
import java.io.IOException;
|
|
import java.util.UUID;
|
|
|
|
@Api(tags = "辅助检查")
|
|
@RestController
|
|
@RequestMapping("askAncillary")
|
|
@RequiredArgsConstructor
|
|
public class AskAncillaryController {
|
|
|
|
|
|
@ApiOperation("接收页面的语音消息(暂时不用这个接口,主要使用websocket进行通信)")
|
|
@PostMapping("/receiveVoiceFile")
|
|
public String receiveVoiceFile(@RequestParam("file") MultipartFile file) throws IOException {
|
|
//return askService.receiveVoiceFile(file);
|
|
|
|
if (file != null && !file.isEmpty()) {
|
|
String fileName1 = file.getOriginalFilename(); //获取保存文件名
|
|
String suffixName=fileName1.substring(fileName1.lastIndexOf(".")); //文件格式
|
|
String fileName= UUID.randomUUID()+suffixName;//重命名a.jpg
|
|
//保存文件到对应位置
|
|
File dir = new File("F:\\tmp\\"+fileName);
|
|
if (!dir.getParentFile().exists()) {
|
|
dir.getParentFile().mkdirs();
|
|
}
|
|
try {
|
|
file.transferTo(dir);
|
|
} catch (IOException e) {
|
|
//抛出异常
|
|
}
|
|
}
|
|
|
|
return "";
|
|
}
|
|
}
|