我从https://github.com/awslabs/aws-sdk-android-samples下载了S3TransferUtilitySample。启动S3TransferUtility |管理上传|上传图片 选择一个图像(我的测试图像是一个大约23M的文件)。然后它开始转移。这是日志:
05-25 21:57:18.527 15463-15463/com.amazonaws.demo.s3transferutility D/TransferSerivce﹕ Starting Transfer Service
05-25 21:57:18.619 15463-15463/com.amazonaws.demo.s3transferutility D/TransferSerivce﹕ Network connected: true
05-25 21:57:18.619 15463-15463/com.amazonaws.demo.s3transferutility D/UploadActivity﹕ onStateChanged: 1, IN_PROGRESS
05-25 21:57:18.619 15463-15463/com.amazonaws.demo.s3transferutility D/UploadActivity﹕ onStateChanged: 1, IN_PROGRESS
05-25 21:57:18.619 15463-15570/com.amazonaws.demo.s3transferutility D/TransferSerivce﹕ Loading transfers from database
05-25 21:57:18.631 15463-15570/com.amazonaws.demo.s3transferutility D/TransferSerivce﹕ 0 transfers are loaded from database
05-25 21:57:19.323 15463-15571/com.amazonaws.demo.s3transferutility D/dalvikvm﹕ GC_FOR_ALLOC freed 202K, 6% free 5004K/5280K, paused 1ms, total 2ms
05-25 21:57:19.975 15463-15571/com.amazonaws.demo.s3transferutility D/UploadTask﹕ multipart upload 1 in 5 parts.
05-25 21:57:19.983 15463-15463/com.amazonaws.demo.s3transferutility D/UploadActivity﹕ onProgressChanged: 1, total: 23669715, current: 0
05-25 21:57:20.007 15463-15463/com.amazonaws.demo.s3transferutility D/UploadActivity﹕ onProgressChanged: 1, total: 23669715, current: 0
05-25 21:57:20.703 15463-15587/com.amazonaws.demo.s3transferutility D/dalvikvm﹕ GC_FOR_ALLOC freed 569K, 12% free 5103K/5744K, paused 3ms, total 3ms
05-25 21:57:21.019 15463-15463/com.amazonaws.demo.s3transferutility D/UploadActivity﹕ onProgressChanged: 1, total: 23669715, current: 696320
05-25 21:57:21.019 15463-15463/com.amazonaws.demo.s3transferutility D/UploadActivity﹕ onProgressChanged: 1, total: 23669715, current: 696320
05-25 21:57:23.847 15463-15463/com.amazonaws.demo.s3transferutility D/UploadActivity﹕ onProgressChanged: 1, total: 23669715, current: 3276800
05-25 21:57:23.851 15463-15463/com.amazonaws.demo.s3transferutility D/UploadActivity﹕ onProgressChanged: 1, total: 23669715, current: 3276800
05-25 21:57:25.199 15463-15463/com.amazonaws.demo.s3transferutility D/UploadActivity﹕ onProgressChanged: 1, total: 23669715, current: 3751936
05-25 21:57:25.199 15463-15463/com.amazonaws.demo.s3transferutility D/UploadActivity﹕ onProgressChanged: 1, total: 23669715, current: 3751936
05-25 21:57:25.635 15463-15588/com.amazonaws.demo.s3transferutility D/dalvikvm﹕ GC_FOR_ALLOC freed 676K, 13% free 5128K/5876K, paused 6ms, total 6ms
05-25 21:57:28.195 15463-15463/com.amazonaws.demo.s3transferutility D/UploadActivity﹕ onProgressChanged: 1, total: 23669715, current: 4423680
05-25 21:57:28.199 15463-15463/com.amazonaws.demo.s3transferutility D/UploadActivity﹕ onProgressChanged: 1, total: 23669715, current: 4423680
05-25 21:57:29.223 15463-15463/com.amazonaws.demo.s3transferutility D/UploadActivity﹕ onProgressChanged: 1, total: 23669715, current: 4620288
05-25 21:57:29.231 15463-15463/com.amazonaws.demo.s3transferutility D/UploadActivity﹕ onProgressChanged: 1, total: 23669715, current: 4620288
05-25 21:57:29.883 517-532/system_process I/ActivityManager﹕ Waited long enough for: ServiceRecord{532611c0 u0 com.artisanstate.photobooks/com.amazonaws.mobileconnectors.s3.transferutility.TransferService}
05-25 21:57:33.307 15463-15463/com.amazonaws.demo.s3transferutility D/UploadActivity﹕ onProgressChanged: 1, total: 23669715, current: 5029888
05-25 21:57:33.315 15463-15463/com.amazonaws.demo.s3transferutility D/UploadActivity﹕ onProgressChanged: 1, total: 23669715, current: 5029888
05-25 21:57:34.435 15463-15463/com.amazonaws.demo.s3transferutility D/UploadActivity﹕ onProgressChanged: 1, total: 23669715, current: 5693440
05-25 21:57:34.439 15463-15463/com.amazonaws.demo.s3transferutility D/UploadActivity﹕ onProgressChanged: 1, total: 23669715, current: 5693440
05-25 21:57:36.427 15463-15463/com.amazonaws.demo.s3transferutility D/UploadActivity﹕ onProgressChanged: 1, total: 23669715, current: 5890048
05-25 21:57:36.439 15463-15463/com.amazonaws.demo.s3transferutility D/UploadActivity﹕ onProgressChanged: 1, total: 23669715, current: 5890048
05-25 21:57:37.619 15463-15463/com.amazonaws.demo.s3transferutility D/UploadActivity﹕ onProgressChanged: 1, total: 23669715, current: 6078464
05-25 21:57:37.635 15463-15463/com.amazonaws.demo.s3transferutility D/UploadActivity﹕ onProgressChanged: 1, total: 23669715, current: 6078464
05-25 21:57:39.107 15463-15463/com.amazonaws.demo.s3transferutility D/UploadActivity﹕ onProgressChanged: 1, total: 23669715, current: 6275072
05-25 21:57:39.115 15463-15463/com.amazonaws.demo.s3transferutility D/UploadActivity﹕ onProgressChanged: 1, total: 23669715, current: 6275072
05-25 21:57:40.539 15463-15463/com.amazonaws.demo.s3transferutility D/UploadActivity﹕ onProgressChanged: 1, total: 23669715, current: 6504448
05-25 21:57:40.543 15463-15463/com.amazonaws.demo.s3transferutility D/UploadActivity﹕ onProgressChanged: 1, total: 23669715, current: 6504448
05-25 21:57:42.011 15463-15463/com.amazonaws.demo.s3transferutility D/UploadActivity﹕ onProgressChanged: 1, total: 23669715, current: 6889472
05-25 21:57:42.019 15463-15463/com.amazonaws.demo.s3transferutility D/UploadActivity﹕ onProgressChanged: 1, total: 23669715, current: 6889472
05-25 21:57:43.503 15463-15463/com.amazonaws.demo.s3transferutility D/UploadActivity﹕ onProgressChanged: 1, total: 23669715, current: 7086080
05-25 21:57:43.507 15463-15463/com.amazonaws.demo.s3transferutility D/UploadActivity﹕ onProgressChanged: 1, total: 23669715, current: 7086080
05-25 21:57:45.999 15463-15463/com.amazonaws.demo.s3transferutility D/UploadActivity﹕ onProgressChanged: 1, total: 23669715, current: 7307264
05-25 21:57:46.007 15463-15463/com.amazonaws.demo.s3transferutility D/UploadActivity﹕ onProgressChanged: 1, total: 23669715, current: 7307264
05-25 21:57:47.503 15463-15463/com.amazonaws.demo.s3transferutility D/UploadActivity﹕ onProgressChanged: 1, total: 23669715, current: 7716864
05-25 21:57:47.503 15463-15463/com.amazonaws.demo.s3transferutility D/UploadActivity﹕ onProgressChanged: 1, total: 23669715, current: 7716864
05-25 21:57:51.139 15463-15463/com.amazonaws.demo.s3transferutility D/UploadActivity﹕ onProgressChanged: 1, total: 23669715, current: 7970816
05-25 21:57:51.143 15463-15463/com.amazonaws.demo.s3transferutility D/UploadActivity﹕ onProgressChanged: 1, total: 23669715, current: 7970816
05-25 21:57:55.495 15463-15463/com.amazonaws.demo.s3transferutility D/UploadActivity﹕ onProgressChanged: 1, total: 23669715, current: 8617984
05-25 21:57:55.499 15463-15463/com.amazonaws.demo.s3transferutility D/UploadActivity﹕ onProgressChanged: 1, total: 23669715, current: 8617984
05-25 21:57:57.799 15463-15463/com.amazonaws.demo.s3transferutility D/UploadActivity﹕ onProgressChanged: 1, total: 23669715, current: 8806400
05-25 21:57:57.799 15463-15463/com.amazonaws.demo.s3transferutility D/UploadActivity﹕ onProgressChanged: 1, total: 23669715, current: 8806400
05-25 21:57:59.507 15463-15463/com.amazonaws.demo.s3transferutility D/UploadActivity﹕ onProgressChanged: 1, total: 23669715, current: 9224192
05-25 21:57:59.507 15463-15463/com.amazonaws.demo.s3transferutility D/UploadActivity﹕ onProgressChanged: 1, total: 23669715, current: 9224192
05-25 21:58:02.007 15463-15463/com.amazonaws.demo.s3transferutility D/UploadActivity﹕ onProgressChanged: 1, total: 23669715, current: 9420800
05-25 21:58:02.007 15463-15463/com.amazonaws.demo.s3transferutility D/UploadActivity﹕ onProgressChanged: 1, total: 23669715, current: 9420800
05-25 21:58:04.775 15463-15463/com.amazonaws.demo.s3transferutility D/UploadActivity﹕ onProgressChanged: 1, total: 23669715, current: 9863168
05-25 21:58:04.775 15463-15463/com.amazonaws.demo.s3transferutility D/UploadActivity﹕ onProgressChanged: 1, total: 23669715, current: 9863168
05-25 21:58:07.519 15463-15463/com.amazonaws.demo.s3transferutility D/UploadActivity﹕ onProgressChanged: 1, total: 23669715, current: 10248192
05-25 21:58:07.523 15463-15463/com.amazonaws.demo.s3transferutility D/UploadActivity﹕ onProgressChanged: 1, total: 23669715, current: 10248192
05-25 21:58:09.283 15463-15463/com.amazonaws.demo.s3transferutility D/UploadActivity﹕ onProgressChanged: 1, total: 23669715, current: 10444800
05-25 21:58:09.287 15463-15463/com.amazonaws.demo.s3transferutility D/UploadActivity﹕ onProgressChanged: 1, total: 23669715, current: 10444800
05-25 21:58:11.187 15463-15463/com.amazonaws.demo.s3transferutility D/UploadActivity﹕ onProgressChanged: 1, total: 23669715, current: 10633216
05-25 21:58:11.187 15463-15463/com.amazonaws.demo.s3transferutility D/UploadActivity﹕ onProgressChanged: 1, total: 23669715, current: 10633216
05-25 21:58:13.095 15463-15463/com.amazonaws.demo.s3transferutility D/UploadActivity﹕ onProgressChanged: 1, total: 23669715, current: 10756096
05-25 21:58:13.103 15463-15463/com.amazonaws.demo.s3transferutility D/UploadActivity﹕ onProgressChanged: 1, total: 23669715, current: 10756096
05-25 21:58:15.319 15463-15463/com.amazonaws.demo.s3transferutility D/UploadActivity﹕ onProgressChanged: 1, total: 23669715, current: 10944512
05-25 21:58:15.323 15463-15463/com.amazonaws.demo.s3transferutility D/UploadActivity﹕ onProgressChanged: 1, total: 23669715, current: 10944512
05-25 21:58:17.883 15463-15463/com.amazonaws.demo.s3transferutility D/UploadActivity﹕ onProgressChanged: 1, total: 23669715, current: 11141120
05-25 21:58:17.883 15463-15463/com.amazonaws.demo.s3transferutility D/UploadActivity﹕ onProgressChanged: 1, total: 23669715, current: 11141120
05-25 21:58:20.759 15463-15463/com.amazonaws.demo.s3transferutility D/UploadActivity﹕ onProgressChanged: 1, total: 23669715, current: 11329536
05-25 21:58:20.759 15463-15463/com.amazonaws.demo.s3transferutility D/UploadActivity﹕ onProgressChanged: 1, total: 23669715, current: 11329536
05-25 21:58:22.855 15463-15463/com.amazonaws.demo.s3transferutility D/UploadActivity﹕ onProgressChanged: 1, total: 23669715, current: 11553747
05-25 21:58:22.855 15463-15463/com.amazonaws.demo.s3transferutility D/UploadActivity﹕ onProgressChanged: 1, total: 23669715, current: 11553747
05-25 21:58:24.311 15463-15463/com.amazonaws.demo.s3transferutility D/UploadActivity﹕ onProgressChanged: 1, total: 23669715, current: 11561939
05-25 21:58:24.315 15463-15463/com.amazonaws.demo.s3transferutility D/UploadActivity﹕ onProgressChanged: 1, total: 23669715, current: 11561939
05-25 21:58:26.431 15463-15463/com.amazonaws.demo.s3transferutility D/UploadActivity﹕ onProgressChanged: 1, total: 23669715, current: 11815891
05-25 21:58:26.435 15463-15463/com.amazonaws.demo.s3transferutility D/UploadActivity﹕ onProgressChanged: 1, total: 23669715, current: 11815891
05-25 21:58:27.495 15463-15463/com.amazonaws.demo.s3transferutility D/UploadActivity﹕ onProgressChanged: 1, total: 23669715, current: 12004307
05-25 21:58:27.503 15463-15463/com.amazonaws.demo.s3transferutility D/UploadActivity﹕ onProgressChanged: 1, total: 23669715, current: 12004307
然后没有更多的日志,进度永远停止!
使用[sdk源代码](https://github.com/aws/aws-sdk-android/)下载并调试后。我无限地在UrlHttpClient.java中找到了程序块:
private void write(InputStream is, OutputStream os) throws IOException {
byte[] buf = new byte[1024 * 8];
int len;
while ((len = is.read(buf)) != -1) {
os.write(buf, 0, len); //block at this line!
}
}
BTW我使用的sdk版本是2.1.17。 有朋友可以帮忙吗?感谢。
答案 0 :(得分:0)
几种可能性: - 监听器未注册。示例应用程序在上载活动暂停时取消注册侦听器,以防止内存泄漏。我没有代码,也不知道你的用例。但请确保听众仍在注册。 - 早期的SDK版本存在让侦听器保持活跃的问题。请使用最新版本v2.2.14(如果您遇到NPE,请使用2.2.13)。