音视频样例配置审核流程(配置下发,配置取消)完善
This commit is contained in:
@@ -9,6 +9,8 @@ import javax.ws.rs.client.WebTarget;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
import javax.ws.rs.core.Response;
|
||||
|
||||
import net.sf.json.JSONObject;
|
||||
|
||||
import org.glassfish.jersey.media.multipart.FormDataMultiPart;
|
||||
import org.glassfish.jersey.media.multipart.file.FileDataBodyPart;
|
||||
|
||||
@@ -95,7 +97,7 @@ public class ConfigServiceUtil {
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
public static String postFileCfg(String params,File file,Map<String, Object> fileDesc) throws Exception{
|
||||
public static String postFileCfg(String params,File file,JSONObject fileDesc) throws Exception{
|
||||
String result = null;
|
||||
String url = Constants.SERVICE_URL+Constants.FILE_UPLOAD_CFG;
|
||||
//创建连接
|
||||
@@ -103,7 +105,7 @@ public class ConfigServiceUtil {
|
||||
FormDataMultiPart formDataMultiPart=new FormDataMultiPart();
|
||||
FileDataBodyPart bodyPart=new FileDataBodyPart("file",file);
|
||||
formDataMultiPart.bodyPart(bodyPart);
|
||||
Builder header = wt.request(MediaType.APPLICATION_JSON).header("File-Desc",ClientUtil.formatFileDesc(fileDesc) );
|
||||
Builder header = wt.request(MediaType.APPLICATION_JSON).header("File-Desc",fileDesc);
|
||||
Response response= header.post(Entity.entity(formDataMultiPart, formDataMultiPart.getMediaType()));
|
||||
if( response.getStatus() == 200){
|
||||
result= response.readEntity(String.class);
|
||||
|
||||
@@ -10,6 +10,7 @@ import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.net.URLEncoder;
|
||||
import java.security.MessageDigest;
|
||||
import java.util.Enumeration;
|
||||
|
||||
import javax.servlet.ServletOutputStream;
|
||||
@@ -666,7 +667,25 @@ public class FileUtils extends org.apache.commons.io.FileUtils {
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取文件前缀
|
||||
*
|
||||
* @param filename
|
||||
* @param isDot
|
||||
* true:加“.”
|
||||
* @return
|
||||
*/
|
||||
public static String getPrefix(String filename, Boolean isDot) {
|
||||
String prefix = "";
|
||||
int pos = filename.lastIndexOf('.');
|
||||
if (pos > 0 && pos < filename.length() - 1) {
|
||||
if (!isDot) {
|
||||
pos = pos - 1;
|
||||
}
|
||||
prefix = filename.substring(0,pos);
|
||||
}
|
||||
return prefix;
|
||||
}
|
||||
/**
|
||||
* 获取文件后缀
|
||||
*
|
||||
@@ -728,4 +747,36 @@ public class FileUtils extends org.apache.commons.io.FileUtils {
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 计算文件MD5
|
||||
* @param file
|
||||
* @return
|
||||
*/
|
||||
public static String getFileMD5(File file){
|
||||
if(!file.isFile()){
|
||||
return "";
|
||||
}
|
||||
String md5 = "";
|
||||
MessageDigest digest=null;
|
||||
FileInputStream in=null;
|
||||
byte[] buffer=new byte[1024];
|
||||
int len;
|
||||
try{
|
||||
digest=MessageDigest.getInstance("MD5");
|
||||
in=new FileInputStream(file);
|
||||
while ((len=in.read(buffer,0,1024)) !=-1) {
|
||||
digest.update(buffer,0,len);
|
||||
}
|
||||
in.close();
|
||||
}catch(Exception e){
|
||||
e.printStackTrace();
|
||||
return "";
|
||||
}
|
||||
byte[] b = digest.digest();
|
||||
for (int i=0; i < b.length; i++) {
|
||||
md5 += Integer.toString( (b[i] & 0xff ) + 0x100, 16).substring(1);//加0x100是因为有的b[i]的十六进制只有1位
|
||||
}
|
||||
// BigInteger bigInt=new BigInteger(1,digest.digest());
|
||||
return md5;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user