Android AWS S3访问被拒绝 [英] Android AWS S3 Access Denied

查看:889
本文介绍了Android AWS S3访问被拒绝的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正尝试使用我的Android应用程序简单地将文件上传到S3存储桶.我已经尝试了他们所说的所有内容,做了所有示例,并使用了第三方库.什么都行不通.运行此代码时,我不断收到访问被拒绝"错误:

I'm trying to simply upload a file to an S3 bucket with my Android app. I've tried everything they've said, did all the examples and used a third party library. Nothing works. I keep getting an Access Denied error when I run this code:

       AmazonS3Client s3Client = new AmazonS3Client( new BasicAWSCredentials("MY KEY", "MY SECRET" ) );
        s3Client.createBucket("evenatir");
        PutObjectRequest por = new PutObjectRequest("BUCKETNAME", "VIDEONAME", new java.io.File("/storage/emulated/0/Movies/outterlimits20.mp4") );
        s3Client.putObject( por );

它在createBucket()处返回此错误消息;方法:

It returns this error message at the createBucket(); method:

     Caused by: com.amazonaws.services.s3.model.AmazonS3Exception: Access Denied (Service: Amazon S3; Status Code: 403; Error Code: AccessDenied; Request ID: F2871EBB4091D6D9), S3 Extended Request ID: gqR4PhULERMiGxVTbzzC71mDoeKZxyRu9mLYMcF+wPaFN8KT6VrqyU+k6i7/Pee0

我还使用了 Android simpl3r库,实际上,令我惊讶的是,它通过了Access拒绝的错误,但是,当然,出现了一些XML格式不正确的错误,AWS尚未对此进行任何处理.我完全被卡住了,我只想将文件上传到我的S3存储桶中!

I also used the Android simpl3r library and actually, to my surprise, got past the Access Denied error but, of course, got some XML not well formed error to which AWS has yet to do anything about. I'm completely stuck, I just want to upload a file to my S3 bucket!

推荐答案

请确保在上传任何文件之前已经创建了要传递的存储桶名称.

Make sure the bucketname your are passing has to be created already before uploading any file.

aws不会引发未找到存储桶的异常,而是会引发访问被拒绝的异常.

Instead of throwing bucket not found exception, aws throws access denied exception.

希望这会对您有所帮助.

Hope this will help you.

这篇关于Android AWS S3访问被拒绝的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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