微信硬件平台接收的图片消息是文件md5值和原文件的md5不一致,并且内容长度也发生了变化?
微信硬件平台的接收微信消息能力,接收图片的时候,download_url下载的文件无法打开,发现文件md5值和原文件md5值不一致,并且文件大小发送变化,报文如下:{"device_id":"gh_b36753c89af2_09cd3e115440cec9","device_type":"gh_b36753c89af2","msg_id":"887006918","msg_type":"set","services":{"wxmsg_file":{"downloadUrl":"http://wxapp.tc.qq.com/202/20303/stodownload?filekey=30340201010420301e020200ca0402535a0410af2a73c0c58201b88285ef67f611272402021000040d00000004627466730000000131&hy=SZ&storeid=32303231303331303137313031383030306139333361363134313832393738656338353730393030303030306361&bizid=1023","md5":"71093817c7f68eb70e90346a157b4e50","name":"80a99f59f472b84942ce20c7ed8f850e.jpg","size":3800,"type":"jpg"},"wxmsg_image":{"downloadUrl":"http://wxapp.tc.qq.com/202/20303/stodownload?filekey=30340201010420301e020200ca0402535a0410af2a73c0c58201b88285ef67f611272402021000040d00000004627466730000000131&hy=SZ&storeid=32303231303331303137313031383030306139333361363134313832393738656338353730393030303030306361&bizid=1023","md5":"71093817c7f68eb70e90346a157b4e50","name":"80a99f59f472b84942ce20c7ed8f850e.jpg","size":3800,"type":"jpg"}},"user":"oleOTjpW_qLjx-oF0B0L91ieMVL4"} 但是该图片是有5,755字节但是下载时候完全不对,并且下载后根本打不开 我下载方式方式代码如下 public static void downloadFile(String remoteFilePath, String localFilePath) {
URL urlfile = null;
HttpURLConnection httpUrl = null;
BufferedInputStream bis = null;
BufferedOutputStream bos = null;
File f = new File(localFilePath);
try {
urlfile = new URL(remoteFilePath);
httpUrl = (HttpURLConnection) urlfile.openConnection();
httpUrl.connect();
bis = new BufferedInputStream(httpUrl.getInputStream());
bos = new BufferedOutputStream(new FileOutputStream(f));
int len = 2048;
byte[] b = new byte[len];
while ((len = bis.read(b)) != -1) {
bos.write(b, 0, len);
}
System.out.println("下载成功");
bos.flush();
bis.close();
httpUrl.disconnect();
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
bis.close();
bos.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}