No se puede crear un depósito en AWS S3

I am trying to create a bucket in amazon S3 service. but the following exception arise:

11-27 05:32:53.868: E/AndroidRuntime(1628): FATAL EXCEPTION: AsyncTask #1
11-27 05:32:53.868: E/AndroidRuntime(1628): java.lang.RuntimeException: An error occured while executing doInBackground()
11-27 05:32:53.868: E/AndroidRuntime(1628):     at android.os.AsyncTask$3.done(
11-27 05:32:53.868: E/AndroidRuntime(1628):     at java.util.concurrent.FutureTask.finishCompletion(
11-27 05:32:53.868: E/AndroidRuntime(1628):     at java.util.concurrent.FutureTask.setException(
11-27 05:32:53.868: E/AndroidRuntime(1628):     at
11-27 05:32:53.868: E/AndroidRuntime(1628):     at android.os.AsyncTask$SerialExecutor$
11-27 05:32:53.868: E/AndroidRuntime(1628):     at java.util.concurrent.ThreadPoolExecutor.runWorker(
11-27 05:32:53.868: E/AndroidRuntime(1628):     at java.util.concurrent.ThreadPoolExecutor$
11-27 05:32:53.868: E/AndroidRuntime(1628):     at
11-27 05:32:53.868: E/AndroidRuntime(1628): Caused by: Status Code: 404, AWS Service: Amazon S3, AWS Request ID: A8BC718C70431BC1, AWS Error Code: NoSuchBucket, AWS Error Message: The specified bucket does not exist, S3 Extended Request ID: /LB0Sfqrke3aDRbuZ51iXbgdESeQFVVijrK8X8Csp2zDzppRQ9G/WOgy0fA71ltI
11-27 05:32:53.868: E/AndroidRuntime(1628):     at com.amazonaws.http.AmazonHttpClient.handleErrorResponse(
11-27 05:32:53.868: E/AndroidRuntime(1628):     at com.amazonaws.http.AmazonHttpClient.executeHelper(
11-27 05:32:53.868: E/AndroidRuntime(1628):     at com.amazonaws.http.AmazonHttpClient.execute(
11-27 05:32:53.868: E/AndroidRuntime(1628):     at
11-27 05:32:53.868: E/AndroidRuntime(1628):     at
11-27 05:32:53.868: E/AndroidRuntime(1628):     at com.demo.amazons3cloudservice.MainActivity.create(
11-27 05:32:53.868: E/AndroidRuntime(1628):     at com.demo.amazons3cloudservice.MainActivity$CreateBucket.doInBackground(
11-27 05:32:53.868: E/AndroidRuntime(1628):     at com.demo.amazons3cloudservice.MainActivity$CreateBucket.doInBackground(
11-27 05:32:53.868: E/AndroidRuntime(1628):     at android.os.AsyncTask$
11-27 05:32:53.868: E/AndroidRuntime(1628):     at
11-27 05:32:53.868: E/AndroidRuntime(1628):     ... 4 more

I have learnt from the exception that the application is not sign in at the aws s3 but could not find out the way, here is my code, please give me any suggestion.


import android.content.Context;
import android.os.AsyncTask;
import android.os.Bundle;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.Toast;

import com.amazonaws.AmazonWebServiceRequest;
import com.amazonaws.auth.BasicAWSCredentials;
import com.amazonaws.http.AmazonHttpClient;
import com.amazonaws.http.HttpRequest;

public class MainActivity extends Activity {

    Button s3Connect;
    private AmazonS3Client client;
    String folderName = "new Folder";

    protected void onCreate(Bundle savedInstanceState) {

        client = new AmazonS3Client(new BasicAWSCredentials(
                Constants.ACCESS_KEY, Constants.ACCESS_SECRET));

        s3Connect =(Button)findViewById(;

        s3Connect.setOnClickListener(new OnClickListener() {
            public void onClick(View arg0) {
                CreateBucket bucket = new CreateBucket(getApplicationContext(),
                        client, folderName);


    private class CreateBucket extends AsyncTask<Boolean, Void, Boolean> {

        private Context mContext;
        private AmazonS3Client mClient;
        private String folderName;

        public CreateBucket(Context mContext, AmazonS3Client mClient,
                String folderName) {
            // TODO Auto-generated constructor stub
            this.mContext = mContext;
            this.mClient = mClient;
            this.folderName = "new";

        protected Boolean doInBackground(Boolean... arg0) {
            // TODO Auto-generated method stub
            return true;

        protected void onPostExecute(Boolean result) {
            // TODO Auto-generated method stub
            if (result == true)
                        "The folder is created", Toast.LENGTH_SHORT).show();
                        "The folder is not created", Toast.LENGTH_SHORT).show();


    public void create(String foldername) {
        // TODO validate foldername

        // Create metadata for your folder & set content-length to 0
        ObjectMetadata metadata = new ObjectMetadata();

        // Create empty content
        InputStream emptyContent = new ByteArrayInputStream(new byte[0]);

        // Create a PutObjectRequest passing the foldername suffixed by /
        PutObjectRequest putObjectRequest = new PutObjectRequest(
                Constants.BUCKET, foldername + "/", emptyContent, metadata);

        // Send request to S3 to create folder

    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(, menu);
        return true;


preguntado el 27 de noviembre de 13 a las 05:11

Your code does not include the actual code to create a bucket. Can you please show the full code for the crear() ¿método? -

okay!! I am Adding the correction. -

Your code does not actually create a bucket. Are you sure the bucket is actually available? The error you are receiving would seem to indicate that it is not. -

Sir!! Will you please tell me that If I use the AWS S3 without providing my credit card information in creating the Amazon web service account? -

Signing up for AWS does require supplying a credit card. For new accounts, there is a free tier where you can operate at little to no cost. See the Sitio web de AWS para detalles. -

1 Respuestas

Make sure the your key which you are using in the code has as it is in the bucket. Remember Amazon S3 keys are case insensitive, means it might be that your key name has some different cases like upper or lower. So check and try again...

respondido 27 nov., 13:05

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.