Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • uploading to amazon s3 from android app

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 348
    Answer it
    // Initialize the Amazon Cognito credentials provider
    CognitoCachingCredentialsProvider credentialsProvider = new CognitoCachingCredentialsProvider(
            getApplicationContext(),
            "us-west-2:45af92a8-2a30-4540-bbd6-a7ec68b9fcd4", // Identity Pool ID
            Regions.US_WEST_2 // Region
    );
    
    // Create an S3 client
    s3 = new AmazonS3Client(credentialsProvider);
    TransferUtility transferUtility = new TransferUtility(s3, getBaseContext());
    TransferObserver observer = transferUtility.upload(
            "krayon-event-photos",      /* The bucket to upload to */
            "eagleton",     /* The key for the uploaded object */
            new File(imagePath)        /* The file where the data to upload exists */
    );
    observer.setTransferListener(new TransferListener(){
    
        @Override
        public void onStateChanged(int id, TransferState state) {
            // do something
            Log.d("log", "state changed. id = "+id+"\tstate = "+state);
        }
    
        @Override
        public void onProgressChanged(int id, long bytesCurrent, long bytesTotal) {
            int percentage = (int) (bytesCurrent/bytesTotal * 100);
    
            //Display percentage transfered to user
            publishProgress(percentage);
            Log.d("log", "onProgressChanged = "+percentage);
        }
    
        @Override
        public void onError(int id, Exception ex) {
            // do something
            Log.d("log", "error in uploading. id = "+id+"\nException = "+ex);
        }
    
    });

     

    I'm getting the following error:-

    -------------------------------------------

     Exception = com.amazonaws.AmazonClientException: Unable to execute HTTP request: Write error: ssl=0xb7461c28: I/O error during system call, Connection reset by peer

 0 Answer(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: