我正在使用下面的代码将文件上传到AWS,它正在上传,但是当互联网连接中断时,由于它不恢复上传过程,我是否缺少任何要添加的内容?
transferManager = Util.getTransferManager(this);
PutObjectRequest request = new PutObjectRequest(HttpUrls.VIDEO_BUCKET_NAME, "original/" + hashkey + ".mp4", file);
request.setCannedAcl(CannedAccessControlList.PublicReadWrite);
// To receive notifications when bytes are transferred, add a
// ProgressListener to your request.
request.setProgressListener(new com.amazonaws.services.s3.model.ProgressListener() {
@Override
public void progressChanged(com.amazonaws.services.s3.model.ProgressEvent progressEvent) {
totalByteRead = totalByteRead + progressEvent.getBytesTransferred();
final int percentage = (int) ((totalByteRead * 100) / totalSize);
handler.post(new Runnable() {
@Override
public void run() {
if (isUploadAborted == false) {
notificationView.setProgressBar(R.id.progressBarUpload, 100, (int) percentage, false);
notificationView.setTextViewText(R.id.textpercentRatio, percentage + "%");
notification.contentView = notificationView;
notificationManager.notify(NOTIFICATION_ID, notification);
}
}
});
com.orhanobut.logger.Logger.d("LiveVideoUpload " + percentage);
if (progressEvent.getEventCode() == ProgressEvent.COMPLETED_EVENT_CODE) {
uploadNotInProgress = true;
com.orhanobut.logger.Logger.d("LiveVideo is UplaodDone ");
uploadLiveStream(file);
}
}
});
// TransferManager processes all transfers asynchronously,
// so this call returns immediately.
upload = transferManager.upload(request);
// Optionally, you can wait for the upload to finish before continuing.
upload.waitForCompletion();