|
|
@ -46,7 +46,6 @@ class HttpThreadTask extends AbsThreadTask<UploadEntity, UploadTaskEntity> { |
|
|
|
private final String BOUNDARY = UUID.randomUUID().toString(); // 边界标识 随机生成
|
|
|
|
private final String BOUNDARY = UUID.randomUUID().toString(); // 边界标识 随机生成
|
|
|
|
private final String PREFIX = "--", LINE_END = "\r\n"; |
|
|
|
private final String PREFIX = "--", LINE_END = "\r\n"; |
|
|
|
private HttpURLConnection mHttpConn; |
|
|
|
private HttpURLConnection mHttpConn; |
|
|
|
private long mCurrentLocation = 0; |
|
|
|
|
|
|
|
private OutputStream mOutputStream; |
|
|
|
private OutputStream mOutputStream; |
|
|
|
|
|
|
|
|
|
|
|
HttpThreadTask(StateConstance constance, IUploadListener listener, |
|
|
|
HttpThreadTask(StateConstance constance, IUploadListener listener, |
|
|
@ -152,12 +151,11 @@ class HttpThreadTask extends AbsThreadTask<UploadEntity, UploadTaskEntity> { |
|
|
|
byte[] buffer = new byte[4096]; |
|
|
|
byte[] buffer = new byte[4096]; |
|
|
|
int bytesRead; |
|
|
|
int bytesRead; |
|
|
|
while ((bytesRead = inputStream.read(buffer)) != -1) { |
|
|
|
while ((bytesRead = inputStream.read(buffer)) != -1) { |
|
|
|
mCurrentLocation += bytesRead; |
|
|
|
STATE.CURRENT_LOCATION += bytesRead; |
|
|
|
mOutputStream.write(buffer, 0, bytesRead); |
|
|
|
mOutputStream.write(buffer, 0, bytesRead); |
|
|
|
if (STATE.isCancel) { |
|
|
|
if (STATE.isCancel) { |
|
|
|
break; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
mListener.onProgress(mCurrentLocation); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
mOutputStream.flush(); |
|
|
|
mOutputStream.flush(); |
|
|
@ -166,7 +164,6 @@ class HttpThreadTask extends AbsThreadTask<UploadEntity, UploadTaskEntity> { |
|
|
|
writer.append(LINE_END); |
|
|
|
writer.append(LINE_END); |
|
|
|
writer.flush(); |
|
|
|
writer.flush(); |
|
|
|
if (STATE.isCancel) { |
|
|
|
if (STATE.isCancel) { |
|
|
|
mListener.onCancel(); |
|
|
|
|
|
|
|
STATE.isRunning = false; |
|
|
|
STATE.isRunning = false; |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|