从Android上传文件到Amazon S3很慢

我已经按照Amazon指南将file upload到Amazon S3,我注意到它太慢了。 上传一个简单的PNG文件大约需要10秒左右。

最初我以为这个问题与线程有关,我已经实现了一个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(); } } 

任何想法来解决这个问题? 谢谢 :)

Solutions Collecting From Web of "从Android上传文件到Amazon S3很慢"