@@ -21,8 +21,8 @@ android {
|
||
| 21 | 21 |
applicationId "ai.pai.lensman" |
| 22 | 22 |
minSdkVersion 14 |
| 23 | 23 |
targetSdkVersion 24 |
| 24 |
- versionCode 1001 |
|
| 25 |
- versionName "1.0.01" |
|
| 24 |
+ versionCode 1002 |
|
| 25 |
+ versionName "1.0.02" |
|
| 26 | 26 |
buildConfigField "boolean", "isTestMode", "true" |
| 27 | 27 |
} |
| 28 | 28 |
signingConfigs {
|
@@ -58,7 +58,8 @@ public class PrinterSettingActivity extends BaseActivity implements PrinterSetti |
||
| 58 | 58 |
@Override |
| 59 | 59 |
public void run() {
|
| 60 | 60 |
try{
|
| 61 |
- qrCodeImg.setImageBitmap(QRCreateUtils.Create2DCode("http://pai.ai/s/"+qrcode, DeviceUtils.dip2px(PrinterSettingActivity.this,240)));
|
|
| 61 |
+ qrCodeImg.setImageBitmap(QRCreateUtils.Create2DCode("http://pai.ai/s/"+qrcode,
|
|
| 62 |
+ DeviceUtils.dip2px(PrinterSettingActivity.this,240))); |
|
| 62 | 63 |
}catch (Exception e){
|
| 63 | 64 |
e.printStackTrace(); |
| 64 | 65 |
} |
@@ -357,7 +357,7 @@ public class OrderDealService extends Service implements Handler.Callback{
|
||
| 357 | 357 |
photoUploadUtils.addTextParameter("session_id", bean.photoBean.sessionId);
|
| 358 | 358 |
photoUploadUtils.addTextParameter("photo_id", String.valueOf(bean.photoBean.photoId));
|
| 359 | 359 |
|
| 360 |
- String result = new String(photoUploadUtils.send(), "UTF-8"); |
|
| 360 |
+ String result = new String(photoUploadUtils.send(false), "UTF-8"); |
|
| 361 | 361 |
JSONObject resultObj = new JSONObject(result); |
| 362 | 362 |
if (resultObj.getInt("status") == 200) {
|
| 363 | 363 |
LogHelper.d("OrderDealService", "上传 UploadTask upload result ok ");
|
@@ -71,6 +71,29 @@ public class PhotoUploadUtils {
|
||
| 71 | 71 |
conn.disconnect(); |
| 72 | 72 |
return out.toByteArray(); |
| 73 | 73 |
} |
| 74 |
+ |
|
| 75 |
+ public byte[] send(boolean isCompress) throws Exception {
|
|
| 76 |
+ initConnection(); |
|
| 77 |
+ conn.connect(); |
|
| 78 |
+ ds = new DataOutputStream(conn.getOutputStream()); |
|
| 79 |
+ if(isCompress){
|
|
| 80 |
+ writeFileParams(); |
|
| 81 |
+ }else{
|
|
| 82 |
+ writeFileParamsWithoutCompress(); |
|
| 83 |
+ } |
|
| 84 |
+ writeStringParams(); |
|
| 85 |
+ paramsEnd(); |
|
| 86 |
+ InputStream in = conn.getInputStream(); |
|
| 87 |
+ ByteArrayOutputStream out = new ByteArrayOutputStream(); |
|
| 88 |
+ int b; |
|
| 89 |
+ while ((b = in.read()) != -1) {
|
|
| 90 |
+ out.write(b); |
|
| 91 |
+ } |
|
| 92 |
+ conn.disconnect(); |
|
| 93 |
+ return out.toByteArray(); |
|
| 94 |
+ } |
|
| 95 |
+ |
|
| 96 |
+ |
|
| 74 | 97 |
//文件上传的connection的一些必须设置 |
| 75 | 98 |
private void initConnection() throws Exception {
|
| 76 | 99 |
conn = (HttpURLConnection) this.url.openConnection(); |
@@ -114,6 +137,27 @@ public class PhotoUploadUtils {
|
||
| 114 | 137 |
// saveUploadFile(value,bmp); |
| 115 | 138 |
} |
| 116 | 139 |
} |
| 140 |
+ |
|
| 141 |
+ //文件数据 |
|
| 142 |
+ private void writeFileParamsWithoutCompress() throws Exception {
|
|
| 143 |
+ Set<String> keySet = fileparams.keySet(); |
|
| 144 |
+ for (Iterator<String> it = keySet.iterator(); it.hasNext();) {
|
|
| 145 |
+ String name = it.next(); |
|
| 146 |
+ File value = fileparams.get(name); |
|
| 147 |
+ ds.writeBytes("--" + boundary + "\r\n");
|
|
| 148 |
+ ds.writeBytes("Content-Disposition: form-data; name=\"" + name
|
|
| 149 |
+ + "\"; filename=\"" + encode(value.getName()) + "\"\r\n"); |
|
| 150 |
+ ds.writeBytes("Content-Type: " + getContentType(value) + "\r\n");
|
|
| 151 |
+ ds.writeBytes("\r\n");
|
|
| 152 |
+ byte[] bmp = getBytes(value); |
|
| 153 |
+ ds.write(bmp); |
|
| 154 |
+ LogHelper.d("czy","upload final file length="+bmp.length);
|
|
| 155 |
+ LogHelper.d("czy","Upload bitmap size:"+bmp.length);
|
|
| 156 |
+ ds.writeBytes("\r\n");
|
|
| 157 |
+// saveUploadFile(value,bmp); |
|
| 158 |
+ } |
|
| 159 |
+ } |
|
| 160 |
+ |
|
| 117 | 161 |
//获取文件的上传类型,图片格式为image/png,image/jpg等。非图片为application/octet-stream |
| 118 | 162 |
private String getContentType(File file) throws Exception {
|
| 119 | 163 |
|