|
@ -13,6 +13,7 @@ import javax.sound.sampled.AudioInputStream;
|
|
import javax.sound.sampled.AudioSystem;
|
|
import javax.sound.sampled.AudioSystem;
|
|
|
|
|
|
import com.fasterxml.jackson.databind.node.ObjectNode;
|
|
import com.fasterxml.jackson.databind.node.ObjectNode;
|
|
|
|
import com.yihu.wlyy.util.CommonUtil;
|
|
import com.yihu.wlyy.util.fastdfs.FastDFSUtil;
|
|
import com.yihu.wlyy.util.fastdfs.FastDFSUtil;
|
|
import io.swagger.annotations.Api;
|
|
import io.swagger.annotations.Api;
|
|
import io.swagger.annotations.ApiParam;
|
|
import io.swagger.annotations.ApiParam;
|
|
@ -174,25 +175,29 @@ public class FileUploadController extends BaseController {
|
|
|
|
|
|
// 上传文件
|
|
// 上传文件
|
|
MultipartFile mf = entity.getValue();
|
|
MultipartFile mf = entity.getValue();
|
|
|
|
|
|
|
|
|
|
//byte audioData[] = mf.getBytes();
|
|
|
|
//AudioFormat af = getAudioFormat();
|
|
|
|
//ByteArrayInputStream bais = new ByteArrayInputStream(audioData);
|
|
|
|
//AudioInputStream ais = new AudioInputStream(bais,af, audioData.length / af.getFrameSize());
|
|
|
|
//File file = new File("temp.wav");
|
|
|
|
//InputStream in = new FileInputStream(file);
|
|
|
|
//AudioSystem.write(ais, AudioFileFormat.Type.WAVE,file);
|
|
|
|
|
|
|
|
|
|
|
|
fileName = mf.getOriginalFilename();
|
|
fileName = mf.getOriginalFilename();
|
|
String fileExt = fileName.substring(fileName.lastIndexOf(".") + 1).toLowerCase();
|
|
|
|
|
|
|
|
if("3".equals(type)){
|
|
if("3".equals(type)){
|
|
fileExt ="mp3";
|
|
|
|
|
|
String tempPath = CommonUtil.saveVoiceToDisk(mf.getInputStream(),fileName);
|
|
|
|
String map3Path = tempPath.substring(0,tempPath.lastIndexOf("."));
|
|
|
|
CommonUtil.changeToMp3(tempPath,map3Path);
|
|
|
|
File tempFile = new File(tempPath);
|
|
|
|
File mp3File = new File(map3Path);
|
|
|
|
ObjectNode objectNode = fastDFSUtil.upload(new FileInputStream(mp3File),".mp3","");
|
|
|
|
tempPaths.add(fastUrl + objectNode.get("groupName").toString().replaceAll("\"","")
|
|
|
|
+ "/" + objectNode.get("remoteFileName").toString().replaceAll("\"",""));
|
|
|
|
if(tempFile!=null){
|
|
|
|
tempFile.delete();
|
|
|
|
}
|
|
|
|
if(mp3File!=null){
|
|
|
|
mp3File.delete();
|
|
|
|
}
|
|
|
|
}else{
|
|
|
|
String fileExt = fileName.substring(fileName.lastIndexOf(".") + 1).toLowerCase();
|
|
|
|
ObjectNode objectNode = fastDFSUtil.upload(mf.getInputStream() ,fileExt,"");
|
|
|
|
tempPaths.add(fastUrl + objectNode.get("groupName").toString().replaceAll("\"","")
|
|
|
|
+ "/" + objectNode.get("remoteFileName").toString().replaceAll("\"",""));
|
|
}
|
|
}
|
|
ObjectNode objectNode = fastDFSUtil.upload(mf.getInputStream() ,fileExt,"");
|
|
|
|
tempPaths.add(fastUrl + objectNode.get("groupName").toString().replaceAll("\"","")
|
|
|
|
+ "/" + objectNode.get("remoteFileName").toString().replaceAll("\"",""));
|
|
|
|
}
|
|
}
|
|
String urls = String.join(",", tempPaths);
|
|
String urls = String.join(",", tempPaths);
|
|
JSONObject json = new JSONObject();
|
|
JSONObject json = new JSONObject();
|