|
com.smarteye.common.Utils 中修改上传文件名方法修改如下:
/**
* 更改扫码录像的上传文件名,不更改本地文件
* @param name
* @param prefixPUID
* @return
*/
public static String getFixName2ForUpload(String name, String prefixPUID) {
if (name.length() == 19) {
return "PU_" + prefixPUID + "_00_" + name;
}
String prefixName;
int len = name.length();
if (name.endsWith(".jpg")) {//照片文件满足PU_ID_00的格式
if (Build.MODEL.equals(MCUDefine.MODEL_HYTERA_ZFY)) {
if (name.contains("PU_" + prefixPUID + "_00_")) {
int indexOf = name.indexOf("_");
String name1 = name.substring(0, indexOf);
String name2 = name.substring(indexOf + 1);
prefixName = name2.substring(0, name2.length() - 4) + "_"
+ name1 + name2.substring(name2.length() - 4);
return prefixName;
}
} else {
return name;
}
}
try {
String type = name.substring(len - 4);
String time = name.substring(len - 19, len - 4);
String other = name.substring(0, len - 20);
if (Build.MODEL.equals(MCUDefine.MODEL_HYTERA_ZFY)) {
String residue = name.substring(0, len - 4);
if (residue.endsWith("_IMP")) {
time = name.substring(len - 23, len -4);
if (len > 23) {
other = name.substring(0, len - 24);
} else {
return "PU_" + prefixPUID + "_00_" + name;
}
}
}
prefixName = "PU_" + prefixPUID + "_00_" + time + "_" + other + type;
} catch (Exception e) {
Log.d(TAG, "update video file name fail" + e.getMessage() + e.toString());
return name;
}
return prefixName;
}
// 设备本地存储的文件名格式有多种,但是上传时必须改成指定格式,携带PU_ID 时间 |
|