Commit 178f4418 by luozhenzhen

添加转义字符替换

parent 56dd266f
......@@ -10,7 +10,7 @@ public class DeviceInfo {
private String os;
private String info;
private String reyunId;
private Long timestamps;
private Long timestamp;
public DeviceInfo() {
}
......@@ -19,7 +19,7 @@ public class DeviceInfo {
this.os = os;
this.info = info;
this.reyunId = reyunId;
timestamps = new Date().getTime();
timestamp = new Date().getTime();
}
public String getOs() {
......@@ -46,11 +46,11 @@ public class DeviceInfo {
this.reyunId = reyunId;
}
public Long getTimestamps() {
return timestamps;
public Long getTimestamp() {
return timestamp;
}
public void setTimestamps(Long timestamps) {
this.timestamps = timestamps;
public void setTimestamp(Long timestamps) {
this.timestamp = timestamps;
}
}
......@@ -194,6 +194,8 @@ public class DeviceService {
reyunIdMap.put("reyunId", reyunId);
//区分系统保存数据
//去掉转义字符
data = StringUtils.isEmpty(data) ? data : data.replaceAll("\\\\", "");
DeviceInfo deviceInfo = new DeviceInfo(osEnum.getVal(), data, reyunId);
deviceInfoDao.insert(deviceInfo);
......@@ -317,6 +319,8 @@ public class DeviceService {
//保存数据
String reyunId = dataObject.getString("reyunId");
//去掉转义字符
data = StringUtils.isEmpty(data) ? data : data.replaceAll("\\\\","");
SensorInfo sensorInfo = new SensorInfo(reyunId, new Date().getTime(), data, osEnum.getVal());
sensorInfoDao.insert(sensorInfo);
return true;
......
......@@ -55,10 +55,8 @@ public class FileEncryptor {
byte[] data = inputStreamToByte(in);
//base64
// char[] aesData = DeformedBase64.encode(data);
// ByteArrayInputStream cin = StringToInputStream(getBytes(aesData));
ByteArrayInputStream cin = StringToInputStream(data);
char[] aesData = DeformedBase64.encode(data);
ByteArrayInputStream cin = StringToInputStream(getBytes(aesData));
// byte[] aesData = SpecialSecret.aes256EncodeB(data, key.getBytes());
// ByteArrayInputStream cin = StringToInputStream(aesData);
......@@ -89,7 +87,7 @@ public class FileEncryptor {
}
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;) {
}
return b;
......@@ -188,12 +186,16 @@ public class FileEncryptor {
if (sourceFile.exists() && sourceFile.isFile()) {
FileInputStream in = new FileInputStream(sourceFile);
byte[] data = inputStreamToByte(in);
char[] aesData = DeformedBase64.encode(data);
ByteArrayInputStream cin = StringToInputStream(getBytes(aesData));
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;
while ((nRead = cin.read()) != -1) {
while ((nRead = in.read()) != -1) {
out.write(nRead);
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