Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/amazon-web-services/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在什么情况下,文件不会从Android上传到aws S3_Android_Amazon Web Services_Amazon S3 - Fatal编程技术网

在什么情况下,文件不会从Android上传到aws S3

在什么情况下,文件不会从Android上传到aws S3,android,amazon-web-services,amazon-s3,Android,Amazon Web Services,Amazon S3,我正试图从我的Android系统上传一个图像到AWS S3。问题是,当我运行这段代码时,它没有显示任何错误,但文件仍然没有上传到S3。我用这个指南来上传我的图片 但它似乎不起作用。如果不上传,会是什么情况 new Thread() { @Override public void run() { // Initialize the Amazon Cognito cred

我正试图从我的Android系统上传一个图像到AWS S3。问题是,当我运行这段代码时,它没有显示任何错误,但文件仍然没有上传到S3。我用这个指南来上传我的图片 但它似乎不起作用。如果不上传,会是什么情况

            new Thread() {
                @Override
                public void run() {

                    // Initialize the Amazon Cognito credentials provider
                    CognitoCachingCredentialsProvider credentialsProvider = new CognitoCachingCredentialsProvider(
                            getApplicationContext(),
                            "us-east-1:????????????????d", // Identity Pool ID
                            Regions.US_EAST_1 // Region
                    );


                    // Instantiate an S3 Client
                    // Create an S3 client
                    AmazonS3 s3 = new AmazonS3Client(credentialsProvider);

                    // Set the region of your s3 bucket
                    s3.setRegion(Region.getRegion(Regions.DEFAULT_REGION));

                    // Instantiate TransferUtility
                    TransferUtility transferUtility = new TransferUtility(s3, getApplicationContext());

                    //Upload a file to amazon s3

                    Log.i("imageFile", imageFile.toString());
                    TransferObserver observer = transferUtility.upload(
                            "foond",     /* The bucket to upload to */
                            "key",    /* The key for the uploaded object */
                            imageFile        /* The file where the data to upload exists */
                    );
                }
            }.start();
此外,为了防止有人询问,该文件不是空的。我已经初始化了它。当我记录图像文件时,它会打印 I/imageFile:/storage/simulated/0/DCIM/Camera/IMG_20160223_134442.jpg


另外,应该注意的是,如果有什么不同的话,当我来自加利福尼亚州时,我必须选择我在北弗吉尼亚州的位置。因为cognito在我所在的地区不可用,所以我不得不在另一个地区发布。

您使用的是什么版本的AWS SDK?你能检查一下观察者,看看有没有上传数据吗?它处于什么状态?你们能通过流读取一点图像以确保它有被读取的权限吗?嗨,我解决了我的问题。我只需要改变地区。默认地区美国东部1。