2017-02-09 1 views
-2

s3 버킷에 이미지를 업로드하고 싶습니다. 나는 this tutorial 같은 파일을 업로드하기 위해 다른 솔루션을 시도했지만 난 항상 SSL 예외로 오류가 발생합니다 :Amazon S3에 Android 파일 업로드

Unable to execute HTTP request: Write error: ssl=0x55a53d5240: I/O error during system call, Connection reset by peer

내가 나쁜 네트워크가 당신이 오류를 얻을 수 있다면이 예외 댓글에 대한 한 의견은 발견했다. 하지만 제 네트워크는 좋습니다.

내 코드는 다음과 같습니다 :

private void uploadImage() { 

    // Initialize the Amazon Cognito credentials provider 
    CognitoCachingCredentialsProvider credentialsProvider = new CognitoCachingCredentialsProvider(
      getContext().getApplicationContext(), 
      "us-west-2:************", // Identity Pool ID 
      Regions.US_WEST_2 // Region 
    ); 


    ClientConfiguration configuration = new ClientConfiguration(); 
    configuration.setConnectionTimeout(50000); 
    configuration.setSocketTimeout(300000); 

    final AmazonS3 s3 = new AmazonS3Client(credentialsProvider, configuration); 

    TransferUtility transferUtility = new TransferUtility(s3, getContext().getApplicationContext()); 

    LocalImage image = mAddImageAdapter.getLocalImage(0); 
    final File mFile = new File(image.getImagePath()); 
    long len = mFile.length(); 

    transferUtility.upload("2y1s-images", mFile.getName(), mFile).setTransferListener(new TransferListener() { 
     @Override 
     public void onStateChanged(int id, TransferState state) { 

      Log.i(TAG, "image upload state: " + state.name()); 
     } 

     @Override 
     public void onProgressChanged(int id, long bytesCurrent, long bytesTotal) { 


      Log.e(TAG, "image upload percentage: " + bytesCurrent + " -" + bytesTotal); 
     } 

     @Override 
     public void onError(int id, Exception ex) { 

      Log.e(TAG, "image upload error: " + ex.getMessage()); 
     } 
    }); 


} 
+0

확인 - 귀하의 목록에 인터넷 퍼미션을 추가하는 것을 잊지 않았습니까? – SteelBytes

+0

예 인터넷에 읽기 및 쓰기 권한이 있습니다 – gokhan

+0

aws sdk의 버전을 사용하고 있습니까? (최신?) – SteelBytes

답변

0

난 후 이일 보냈다 예외 ​​이유를 발견했다. ssl 예외의 주된 이유는 다른 지역의 내인지 인증 및 s3 버킷입니다. 이 답변이 다른 사람들에게 도움이되기를 바랍니다.