扫描运单通知(图片)
<h3>功能描述</h3>
<ul>
<li>该接口用于:高拍仪扫描图片后,将图片通知至快递管家。
<pre><code>此接口验签需获取File_Md5(md5字符串生成方法在页面末)再使用md5字符串做body体生成签名。</code></pre></li>
</ul>
<h3>接口定义</h3>
<table>
<thead>
<tr>
<th style="text-align: center;">服务名称</th>
<th style="text-align: center;">批量交易</th>
<th style="text-align: center;">接口类型</th>
<th style="text-align: center;">Body</th>
<th>接口uri</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align: center;">扫描运单通知(图片)</td>
<td style="text-align: center;">不支持</td>
<td style="text-align: center;">接入/POST</td>
<td style="text-align: center;">form-data</td>
<td>/public/smallPostOffice/sendFile</td>
</tr>
</tbody>
</table>
<h3>元素<请求></h3>
<table>
<thead>
<tr>
<th style="text-align: center;">序号</th>
<th style="text-align: center;">字段名</th>
<th style="text-align: center;">类型(约束)</th>
<th style="text-align: center;">必填</th>
<th style="text-align: center;">描述</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align: center;">1</td>
<td style="text-align: center;">file</td>
<td style="text-align: center;">File</td>
<td style="text-align: center;">是</td>
<td style="text-align: center;">扫描图片,文件的文件名必须带扩展名,如.pdf;文件限制:多页文件大小需<=20M,单页文件大小需<=9M;文件类型限制:pdf、doc、docx、xls、xlsx、ppt、pptx、wps、jpg、jpeg、bmp、png;文件名请不要包含特殊字符</td>
</tr>
</tbody>
</table>
<h3><请求头></h3>
<table>
<thead>
<tr>
<th style="text-align: center;">序号</th>
<th style="text-align: center;">字段名</th>
<th style="text-align: center;">类型(约束)</th>
<th style="text-align: center;">必填</th>
<th style="text-align: center;">描述</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align: center;">1</td>
<td style="text-align: center;">File_Remark</td>
<td style="text-align: center;">String</td>
<td style="text-align: center;">否</td>
<td style="text-align: center;">文件备注,需要经过Unicode编码,文档</td>
</tr>
<tr>
<td style="text-align: center;">2</td>
<td style="text-align: center;">File_Md5</td>
<td style="text-align: center;">String</td>
<td style="text-align: center;">是</td>
<td style="text-align: center;">文件MD5信息</td>
</tr>
<tr>
<td style="text-align: center;">3</td>
<td style="text-align: center;">hardwareIdCard</td>
<td style="text-align: center;">String(100)</td>
<td style="text-align: center;">是</td>
<td style="text-align: center;">硬件ID</td>
</tr>
</tbody>
</table>
<ul>
<li>文档后半部分提供文件备注Unicode编码和微派文件MD5计算方法</li>
</ul>
<h3>元素<响应></h3>
<table>
<thead>
<tr>
<th style="text-align: center;">序号</th>
<th style="text-align: center;">字段名</th>
<th style="text-align: center;">类型(约束)</th>
<th style="text-align: center;">必填</th>
<th style="text-align: center;">描述</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align: center;">1</td>
<td style="text-align: center;">msg</td>
<td style="text-align: center;">String (200)</td>
<td style="text-align: center;">否</td>
<td style="text-align: center;">提示信息</td>
</tr>
<tr>
<td style="text-align: center;">2</td>
<td style="text-align: center;">succ</td>
<td style="text-align: center;">String (10)</td>
<td style="text-align: center;">是</td>
<td style="text-align: center;">返回成功或失败信息(ok/fail)</td>
</tr>
<tr>
<td style="text-align: center;">3</td>
<td style="text-align: center;">result</td>
<td style="text-align: center;">String</td>
<td style="text-align: center;">否</td>
<td style="text-align: center;">数据,通常为uuid</td>
</tr>
</tbody>
</table>
<h3>报文范例</h3>
<ul>
<li>
<p><strong>请求方式(postman示例)POST:form-data</strong>
<img src="https://www.showdoc.com.cn/server/api/attachment/visitFile?sign=ddcdfd1af69ef37bb86fb80db31a206c&amp;file=file.png" alt="" /></p>
</li>
<li><strong>响应报文</strong>
<ul>
<li>成功报文
<pre><code>{
&quot;result&quot;: &quot;b1cf55b7d5474310985f1d94ee125bf7&quot;,
&quot;succ&quot;: &quot;ok&quot;,
&quot;msg&quot;: &quot;接收成功&quot;
}</code></pre></li>
<li>失败报文-范例
<pre><code>{
&quot;msg&quot;:&quot;文件MD5值不一致&quot;,
&quot;result&quot;: &quot;b1cf55b7d5474310985f1d94ee125bf7&quot;,
&quot;succ&quot;: &quot;fail&quot;
}</code></pre></li>
</ul></li>
</ul>
<h3>其它信息</h3>
<ul>
<li>微派Unicode编码方法
<pre><code>public static String gbEncoding(String gbString) {
char[] utfBytes = gbString.toCharArray();
String unicodeBytes = &quot;&quot;;
for (int i = 0; i &lt; utfBytes.length; i++) {
String hexB = Integer.toHexString(utfBytes[i]);
if (hexB.length() &lt;= 2) {
hexB = &quot;00&quot; + hexB;
}
unicodeBytes = unicodeBytes + &quot;\\u&quot; + hexB;
}
return unicodeBytes;
}</code></pre></li>
<li>微派文件MD5计算方法
<pre><code>/***
* 计算字符串的Content-MD5
* @param str 文件路径
* @return
*/
public static String getStringContentMD5(String str) {
// 获取文件MD5的二进制数组(128位)
byte[] bytes = getFileMD5Bytes1282(str);
// 对文件MD5的二进制数组进行base64编码
return new String(Base64.encodeBase64(bytes));
}
/***
* 获取文件MD5-二进制数组(128位)
*
* @param filePath
* @return
* @throws IOException
*/
public static byte[] getFileMD5Bytes1282(String filePath) {
FileInputStream fis = null;
byte[] md5Bytes = null;
try {
File file = new File(filePath);
fis = new FileInputStream(file);
MessageDigest md5 = MessageDigest.getInstance(&quot;MD5&quot;);
byte[] buffer = new byte[1024];
int length = -1;
while ((length = fis.read(buffer, 0, 1024)) != -1) {
md5.update(buffer, 0, length);
}
md5Bytes = md5.digest();
fis.close();
} catch (FileNotFoundException e) {
System.out.println(e.getMessage());
e.printStackTrace();
} catch (NoSuchAlgorithmException e) {
System.out.println(e.getMessage());
e.printStackTrace();
} catch (IOException e) {
System.out.println(e.getMessage());
e.printStackTrace();
}
return md5Bytes;
}</code></pre></li>
<li>
<p>微派文件MD5计算方法</p>
<pre><code>/***
* 计算字符串的Content-MD5
* @param file 文件
* @return
*/
public static String getStringContentMd5(MultipartFile file) {
// 获取文件MD5的二进制数组(128位)
byte[] bytes = getFileMd5Bytes1282(file);
// 对文件MD5的二进制数组进行base64编码
return new String(Base64.encodeBase64(bytes));
}
/***
* 获取文件MD5-二进制数组(128位)
*
* @param file
* @return
* @throws IOException
*/
public static byte[] getFileMd5Bytes1282(MultipartFile file) {
byte[] md5Bytes = null;
try {
InputStream inputStream = file.getInputStream();
MessageDigest md5 = MessageDigest.getInstance(&quot;MD5&quot;);
byte[] buffer = new byte[1024];
int length = -1;
while ((length = inputStream.read(buffer, 0, 1024)) != -1) {
md5.update(buffer, 0, length);
}
md5Bytes = md5.digest();
inputStream.close();
} catch (FileNotFoundException e) {
System.out.println(e.getMessage());
e.printStackTrace();
} catch (NoSuchAlgorithmException e) {
System.out.println(e.getMessage());
e.printStackTrace();
} catch (IOException e) {
System.out.println(e.getMessage());
e.printStackTrace();
}
return md5Bytes;
}</code></pre>
</li>
</ul>