大佬教程收集整理的这篇文章主要介绍了从Android上传到Amazon S3的文件缓慢,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
最初我以为这个问题与线程有关,我已经实现了一个AsyncTask来上传图像,但问题依然存在.以下是用于上传图像的代码.
private class UploadFileTask extends AsyncTask<String,Integer,String> { String remotePath; String remoteFilename; File file; Context context; S3UploadInterface listener; public UploadFileTask(Context context,String remotePath,String remoteFilename,File file,S3UploadInterface listener){ this.context=context; this.remotePath=remotePath; this.remoteFilename=remoteFilename; this.file=file; this.listener=listener; } protected String doInBACkground(String... params) { credentialsProvider = new CognitoCachingCredentialsProvider(context,"MY_PRIVATE_CREDENTIAL",RegionS.US_EAST_1); TransfeRMANager transfeRMANager = new TransfeRMANager(credentialsProvider); Upload upload = transfeRMANager.upload(remotePath,remoteFilename,filE); TransferProgress transferred = upload.getProgress(); while (!upload.isDone()) { try { publishProgress((int) transferred.getPercentTransferred()); } catch (Exception E) { listener.uploadFailed(E); } } return "uploaded"; } protected void onProgressupdate(Integer... progress) { if (listener!=null) listener.currentUploadProgress(progress[0]); } protected void onPostExecute(String result) { if (listener!=null) listener.uploadCompleted(); } }
有什么想法来解决这个问题吗?
谢谢 :)
以上是大佬教程为你收集整理的从Android上传到Amazon S3的文件缓慢全部内容,希望文章能够帮你解决从Android上传到Amazon S3的文件缓慢所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。