Amazon S3 putObject提供0字节的jpg文件

时间:2015-09-01 13:52:27

标签: amazon-s3 android-camera android-camera-intent

我正在尝试将jpg文件上传到Amazon S3。由于某种原因,该文件在Amazon S3上显示0个字节。

public static String uploadImage(AmazonS3Client s3Client, File file) {
        Log.d(God.LOG_TAG, "Uploading " + file.getName());
        try {
            s3Client.putObject(new PutObjectRequest(AWS_S3_BUCKET, file
                    .getName(), file));
            return file.getName();
        } catch (AmazonClientException e) {
            Log.e(God.LOG_TAG, "Unable to upload image ");
            e.printStackTrace();
            return null;
        }
    }


Object: 65437photo1441115278903.jpg
Bucket: mybucket
Name:   65437photo1441115278903.jpg
Link:   
This is a private link
https://somesite.amazon.aws/mybucket/65437photo1441115278903.jpg
Size:   0
Last Modified:  Tue Sep 01 19:18:18 GMT+530 2015
Owner:  tech
ETag:   ajdlf;jaskldfjasldjfsjdflkjk
Expiry Date:    None
Expiration Rule:    N/A

我错过了什么?

1 个答案:

答案 0 :(得分:0)

我使用的是有缺陷的Android相机代码

  String name=  "pic"+new Date().getTime();
            File photoFile = File.createTempFile(name, ".jpg");
            Log.i(TAG, "created file:"+name+".jpg");
            mImageUri = Uri.fromFile(photoFile);
            takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, mImageUri);
            startActivityForResult(takePictureIntent, ActionCode.TAKE_PHOTO)

现在我将其修复到Building a Camera App部分并手动处理相机。

Using Existing Camera Apps 错误且不可行