Skip to content

Commit

Permalink
add: 电台支持wav格式的文件
Browse files Browse the repository at this point in the history
  • Loading branch information
yangrunkang committed Apr 25, 2023
1 parent 25b846a commit d0c030b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,14 @@ protected Boolean hit() {
protected InputStream getUploadInputStream() throws IOException {
// 检查文件类型
String fileType = FileUtils.getFileType(file.getInputStream());
List<String> detectTypes = Lists.newArrayList("audio/mpeg", "application/octet-stream");
List<String> detectTypes = Lists.newArrayList("audio/mpeg", "application/octet-stream", "audio/vnd.wave");
if (!detectTypes.contains(fileType.toLowerCase())) {
throw new BusinessException(ErrorCode.PARAM_ERROR, "禁止上传非mp3或aac文件");
throw new BusinessException(ErrorCode.PARAM_ERROR, "禁止上传非mp3、aac、wav文件");
}

// 校验文件后缀
String suffix = getFileSuffix(file);
List<String> supportFileType = Lists.newArrayList("mp3", "aac");
List<String> supportFileType = Lists.newArrayList("mp3", "aac", "wav");
if (!supportFileType.contains(suffix.toLowerCase())) {
throw new BusinessException(ErrorCode.PARAM_ERROR, "文件类型必须是mp3或aac格式");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
<div class="form-group mb-3">
<label class="text-black-50">上传电台音频文件</label>
<div class="input-group mb-3">
<input type="file" class="form-control custom-file-input" accept=".mp3,.aac" id="radio-file" aria-describedby="radio-file">
<input type="file" class="form-control custom-file-input" accept=".mp3,.aac,.wav" id="radio-file" aria-describedby="radio-file">
</div>
</div>
<div class="mb-3 ui form">
Expand Down

0 comments on commit d0c030b

Please sign in to comment.