Commit 178f4418 by luozhenzhen

添加转义字符替换

parent 56dd266f
...@@ -10,7 +10,7 @@ public class DeviceInfo { ...@@ -10,7 +10,7 @@ public class DeviceInfo {
private String os; private String os;
private String info; private String info;
private String reyunId; private String reyunId;
private Long timestamps; private Long timestamp;
public DeviceInfo() { public DeviceInfo() {
} }
...@@ -19,7 +19,7 @@ public class DeviceInfo { ...@@ -19,7 +19,7 @@ public class DeviceInfo {
this.os = os; this.os = os;
this.info = info; this.info = info;
this.reyunId = reyunId; this.reyunId = reyunId;
timestamps = new Date().getTime(); timestamp = new Date().getTime();
} }
public String getOs() { public String getOs() {
...@@ -46,11 +46,11 @@ public class DeviceInfo { ...@@ -46,11 +46,11 @@ public class DeviceInfo {
this.reyunId = reyunId; this.reyunId = reyunId;
} }
public Long getTimestamps() { public Long getTimestamp() {
return timestamps; return timestamp;
} }
public void setTimestamps(Long timestamps) { public void setTimestamp(Long timestamps) {
this.timestamps = timestamps; this.timestamp = timestamps;
} }
} }
...@@ -194,6 +194,8 @@ public class DeviceService { ...@@ -194,6 +194,8 @@ public class DeviceService {
reyunIdMap.put("reyunId", reyunId); reyunIdMap.put("reyunId", reyunId);
//区分系统保存数据 //区分系统保存数据
//去掉转义字符
data = StringUtils.isEmpty(data) ? data : data.replaceAll("\\\\", "");
DeviceInfo deviceInfo = new DeviceInfo(osEnum.getVal(), data, reyunId); DeviceInfo deviceInfo = new DeviceInfo(osEnum.getVal(), data, reyunId);
deviceInfoDao.insert(deviceInfo); deviceInfoDao.insert(deviceInfo);
...@@ -317,6 +319,8 @@ public class DeviceService { ...@@ -317,6 +319,8 @@ public class DeviceService {
//保存数据 //保存数据
String reyunId = dataObject.getString("reyunId"); String reyunId = dataObject.getString("reyunId");
//去掉转义字符
data = StringUtils.isEmpty(data) ? data : data.replaceAll("\\\\","");
SensorInfo sensorInfo = new SensorInfo(reyunId, new Date().getTime(), data, osEnum.getVal()); SensorInfo sensorInfo = new SensorInfo(reyunId, new Date().getTime(), data, osEnum.getVal());
sensorInfoDao.insert(sensorInfo); sensorInfoDao.insert(sensorInfo);
return true; return true;
......
...@@ -55,10 +55,8 @@ public class FileEncryptor { ...@@ -55,10 +55,8 @@ public class FileEncryptor {
byte[] data = inputStreamToByte(in); byte[] data = inputStreamToByte(in);
//base64 //base64
// char[] aesData = DeformedBase64.encode(data); char[] aesData = DeformedBase64.encode(data);
// ByteArrayInputStream cin = StringToInputStream(getBytes(aesData)); ByteArrayInputStream cin = StringToInputStream(getBytes(aesData));
ByteArrayInputStream cin = StringToInputStream(data);
// byte[] aesData = SpecialSecret.aes256EncodeB(data, key.getBytes()); // byte[] aesData = SpecialSecret.aes256EncodeB(data, key.getBytes());
// ByteArrayInputStream cin = StringToInputStream(aesData); // ByteArrayInputStream cin = StringToInputStream(aesData);
...@@ -89,7 +87,7 @@ public class FileEncryptor { ...@@ -89,7 +87,7 @@ public class FileEncryptor {
} }
public static byte[] inputStreamToByte(InputStream input) throws IOException{ public static byte[] inputStreamToByte(InputStream input) throws IOException{
byte[] b = new byte[input.available()]; byte[] b = new byte[4096];
for (int n; (n = input.read(b)) != -1;) { for (int n; (n = input.read(b)) != -1;) {
} }
return b; return b;
...@@ -188,12 +186,16 @@ public class FileEncryptor { ...@@ -188,12 +186,16 @@ public class FileEncryptor {
if (sourceFile.exists() && sourceFile.isFile()) { if (sourceFile.exists() && sourceFile.isFile()) {
FileInputStream in = new FileInputStream(sourceFile); FileInputStream in = new FileInputStream(sourceFile);
byte[] data = inputStreamToByte(in);
char[] aesData = DeformedBase64.encode(data);
ByteArrayInputStream cin = StringToInputStream(getBytes(aesData));
out = resp.getOutputStream(); out = resp.getOutputStream();
// byte[] cache = new byte[CACHE_SIZE];
// int nRead = 0;
// while ((nRead = in.read(cache)) != -1) {
// out.write(cache, 0, nRead);
// out.flush();
// }
int nRead = 0; int nRead = 0;
while ((nRead = cin.read()) != -1) { while ((nRead = in.read()) != -1) {
out.write(nRead); out.write(nRead);
out.flush(); out.flush();
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment