上载文件不适用于Android中的TransferUtility Amazon S3 [英] Uploading files doesn't work with TransferUtility Amazon S3 in Android

查看:433
本文介绍了上载文件不适用于Android中的TransferUtility Amazon S3的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试将虚拟文本文件上传到Amazon S3.但是它不起作用,但是日志生成了一个ID.当我刷新Amazon S3存储桶仪表板时.该文件尚未传输.

Hi I have tried to upload a dummy textfile to Amazon S3. however it doesn't work but the log generated an id. When I refresh the Amazon S3 bucket dashboard. the file hasn't been transferred.

public class AmazonService extends AsyncTask<String, Boolean, Boolean> {
    Context mContext;
    public AmazonService(Context context) {
        mContext = context;
    }

    @Override
    protected Boolean doInBackground(String... params) {
        CognitoCachingCredentialsProvider credentialsProvider = new CognitoCachingCredentialsProvider(
                mContext,
                "us-east-1:ec361bf5-52b9-477b-9a68-7e2b5f70de07", // Identity Pool ID
                Regions.US_EAST_1 // Region
        );
        AmazonS3Client client =
                new AmazonS3Client(credentialsProvider);
        TransferUtility transferUtility = new TransferUtility(client, mContext);
        TransferObserver observer = transferUtility.upload("elevator-app","Video/",new File("dummy.txt") );
        Log.d("Test", observer.getId() + " " + observer.getBytesTransferred());

        return true;
    }
}

//AndroidManifest.xml中需要具备的服务

//Service that is needed to have in AndroidManifest.xml

<service android:name= "com.amazonaws.mobileconnectors.s3.transferutility.TransferService" android:enabled="true" />

推荐答案

我遇到了同样的问题,原因是我将服务标签放在了应用标签之外.当我将service标签放在application标签内时,一切工作正常.

I had the same problem, the reason was that I put the service tag outside the application tag. When I put the service tag inside the application tag everything worked perfectly.

这篇关于上载文件不适用于Android中的TransferUtility Amazon S3的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆