使用aws sdk上传图片为android

时间:2013-12-28 21:54:06

标签: android amazon-web-services amazon-s3

我尝试使用适用于Android的AWS sdk上传图片。我收到以下错误

12-28 16:41:41.476: E/AndroidRuntime(1098): FATAL EXCEPTION: main
12-28 16:41:41.476: E/AndroidRuntime(1098): java.lang.NoClassDefFoundError: com.amazonaws.services.s3.AmazonS3Client
12-28 16:41:41.476: E/AndroidRuntime(1098):     at com.example.s3uploader.MainActivity.onActivityResult(MainActivity.java:92)
12-28 16:41:41.476: E/AndroidRuntime(1098):     at android.app.Activity.dispatchActivityResult(Activity.java:5322)

任何帮助,请

switch(requestCode) 
    { 
             case SELECT_PHOTO:
             if(resultCode == RESULT_OK)

             { 
                 Cursor cursor = null;
                  try { 
                      Uri selectedImage = imageReturnedIntent.getData();
                    String[] proj = { MediaStore.Images.Media.DATA };
                    cursor = this.getContentResolver().query(selectedImage,  proj, null, null, null);
                    int column_index = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
                    cursor.moveToFirst();
                    String path =cursor.getString(column_index);
                    Log.d("TAG", "VALUE OF PATH  = " + path);

                    AmazonS3Client s3Client = new AmazonS3Client( new BasicAWSCredentials("hut69988sj98jiok", "jujhyt893807520" ) );


                    PutObjectRequest por = new PutObjectRequest( "mybucket", "25Upload", new java.io.File( path) );  
                    s3Client.putObject( por );



                  } finally {
                    if (cursor != null) {
                      cursor.close();
                    }
                  }

             }



    }

2 个答案:

答案 0 :(得分:0)

如您在其他问题上所述,您可能需要按照this blog post中提到的其他步骤删除此特定异常。

答案 1 :(得分:0)

以防万一有人正在寻找亚马逊的完整示例providad

http://aws.amazon.com/articles/3002109349624271