2016-09-21 2 views
0

/* 이미지를 캡처하고 S3 버킷에 업로드 AWS 샘플 코드에 전달. */는 AWS에 이미지를 업로드 할 S3 실패

@Override 
protected void onActivityResult(int requestCode, int resultCode, Intent resultData) { 
    super.onActivityResult(requestCode, resultCode, resultData); 

    if (resultData != null) { 

     String[] projection = {MediaStore.Images.Media.DATA}; 
     Cursor cursor = managedQuery(
       MediaStore.Images.Media.EXTERNAL_CONTENT_URI, 
       projection, null, null, null); 
     int column_index_data = cursor 
       .getColumnIndexOrThrow(MediaStore.Images.Media.DATA); 
     cursor.moveToLast(); 

     String uri = cursor.getString(column_index_data); 
     Bitmap bitmapImage = BitmapFactory.decodeFile(uri); 
     iv.setImageURI(parse(uri)); 

     System.out.print(uri); 
     Log.e("Uri", String.valueOf(uri)); 
     Upload_image upload = new Upload_image(activity); 

     upload.beginUpload(uri); 
    } 
} 

/* 메인 스레드로 S3에 업로드 AsyncTask를을 사용하여이 점점 무거운 */

class UploadFilesTask extends AsyncTask<String , Integer, String> { 
    String filepath; 
    public UploadFilesTask(String filepath){this.filepath = filepath;} 
    @Override 
    protected String doInBackground(String... params) { 
     File file = new File(filepath); 

     TransferObserver observer = transferUtility.upload(Constants.BUCKET_NAME, file.getName(), 
       file); 
     return null; 
    } 

/* 로그 캣 응답 : 나는 이미지를 우리에게 가져 오는 동안 오류없이

16:54:48.064 2424-2424/com.example.rinzinchoephel.drivervolley E/Uri: /storage/emulated/0/DCIM/Camera/IMG_20160921_165440968.jpg 

                      [ 09-21 16:54:48.246 2424: 2424 W/   ] 
                      Unable to open '/system/framework/prcui-config.jar': No such file or directory 
09-21 16:54:48.246 2424-2424/com.example.rinzinchoephel.drivervolley W/art: Failed to open zip archive '/system/framework/prcui-config.jar': I/O Error 

                      [ 09-21 16:54:48.248 2424: 2424 W/   ] 
                      Unable to open '/system/framework/prcui-config.jar': No such file or directory 
09-21 16:54:48.248 2424-2424/com.example.rinzinchoephel.drivervolley W/art: Failed to open zip archive '/system/framework/prcui-config.jar': I/O Error 
09-21 16:54:48.259 2424-2424/com.example.rinzinchoephel.drivervolley D/CognitoCachingCredentialsProvider: Loading credentials from SharedPreferences 

                              [ 09-21 16:54:48.267 2424: 2424 W/   ] 
                              Unable to open '/system/framework/prcui-config.jar': No such file or directory 
09-21 16:54:48.267 2424-2424/com.example.rinzinchoephel.drivervolley W/art: Failed to open zip archive '/system/framework/prcui-config.jar': I/O Error 

                      [ 09-21 16:54:48.269 2424: 2424 W/   ] 
                      Unable to open '/system/framework/prcui-config.jar': No such file or directory 
09-21 16:54:48.269 2424-2424/com.example.rinzinchoephel.drivervolley W/art: Failed to open zip archive '/system/framework/prcui-config.jar': I/O Error 
09-21 16:54:48.280 2424-4787/com.example.rinzinchoephel.drivervolley E/asyncfilePath: /storage/emulated/0/DCIM/Camera/IMG_20160921_165440968.jpg 
09-21 16:54:48.280 2424-4787/com.example.rinzinchoephel.drivervolley E/asyncfilegetName: IMG_20160921_165440968.jpg 
09-21 16:54:48.280 2424-4787/com.example.rinzinchoephel.drivervolley E/asyncTranUtility: co[email protected]374bc1e 
09-21 16:54:48.339 2424-2424/com.example.rinzinchoephel.drivervolley D/TransferService: Starting Transfer Service 
09-21 16:54:48.909 2424-2424/com.example.rinzinchoephel.drivervolley D/TransferService: Network connected: true 
09-21 16:54:48.909 2424-2424/com.example.rinzinchoephel.drivervolley I/Choreographer: Skipped 32 frames! The application may be doing too much work on its main thread. 
09-21 16:54:48.910 2424-4788/com.example.rinzinchoephel.drivervolley D/TransferService: Loading transfers from database 
09-21 16:54:48.912 2424-4788/com.example.rinzinchoephel.drivervolley D/TransferService: 0 transfers are loaded from database 
09-21 16:55:48.969 2424-4788/com.example.rinzinchoephel.drivervolley D/TransferService: Stop self 

답변

3

을 업로드하려고 할 때 실패 원래 의도를 반환하면 원본 이미지가 반환됩니다. 이미지 크기가 너무 큽니다 (거의 2MB). 이미지를 압축하고 업로드하십시오. http://droidmentor.com/pick-image-from-gallery-or-camera/

:

ByteArrayOutputStream bytes = new ByteArrayOutputStream(); 
photo.compress(Bitmap.CompressFormat.PNG, 80, bytes); 

더 자세한 사항은이 링크를 확인