语音文件上传方法修改
This commit is contained in:
parent
a440ba3437
commit
cf34968f4d
@ -1,6 +1,7 @@
|
||||
package club.joylink.rtss.services;
|
||||
|
||||
import club.joylink.rtss.exception.BusinessExceptionAssertEnum;
|
||||
import club.joylink.rtss.services.file.IFileManagerService;
|
||||
import club.joylink.rtss.util.JsonUtils;
|
||||
import club.joylink.rtss.vo.CommonJsonResponse;
|
||||
import club.joylink.rtss.vo.client.VoiceRecognitionResult;
|
||||
@ -9,8 +10,6 @@ import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
import net.bytebuddy.utility.RandomString;
|
||||
import org.springframework.core.io.FileSystemResource;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.util.LinkedMultiValueMap;
|
||||
import org.springframework.util.MultiValueMap;
|
||||
@ -61,8 +60,6 @@ public interface IVoiceService {
|
||||
saveFile = new File(localFilePath);
|
||||
//上传文件
|
||||
String url = "https://upload.joylink.club/api/upload/AUDIO?appId=00001&appSecret=joylink00001";
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
headers.setContentType(MediaType.MULTIPART_FORM_DATA);
|
||||
MultiValueMap<String, Object> map = new LinkedMultiValueMap<>();
|
||||
map.add("file", new FileSystemResource(saveFile));
|
||||
RestTemplate restTemplate = new RestTemplate();
|
||||
@ -93,9 +90,8 @@ public interface IVoiceService {
|
||||
"audio/wave".equals(contentType) || "audio/wav".equals(contentType) || "audio/x-wav".equals(contentType),
|
||||
String.format("不支持的文件格式[%s]", contentType));
|
||||
try {
|
||||
InputStream inputStream = file.getInputStream();
|
||||
return saveFile(inputStream);
|
||||
} catch (IOException e) {
|
||||
return IFileManagerService.upload(file, "AUDIO", "00001", "joylink00001", ".wav");
|
||||
} catch (Exception e) {
|
||||
throw BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.exception("语音文件上传失败", e);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user