【发布时间】:2013-02-04 01:27:58
【问题描述】:
我在尝试使用 amazon S3 android 库上传使用相机拍照时获得的图像时遇到问题。
保存图片
File _photoFile = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DCIM), (cal.getTimeInMillis() + ".jpg"));
try {
if (_photoFile.exists() == false) {
_photoFile.getParentFile().mkdirs();
_photoFile.createNewFile();
}
} catch (IOException e) {
// Log.e(TAG, "Could not create file.", e);
}
// Log.i(TAG, path);
filePath = Uri.fromFile(_photoFile);
Intent cameraIntent = new Intent(
android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
cameraIntent.putExtra(MediaStore.EXTRA_OUTPUT, filePath);
startActivityForResult(cameraIntent, 1);
用文件路径上传图片:
try {
s3Client.createBucket(Constants.getPictureBucket());
// Content type is determined by file extension.
PutObjectRequest por = new PutObjectRequest(
Constants.getPictureBucket(), Constants.PICTURE_NAME,
new java.io.File(filePath));
s3Client.putObject(por);
} catch (Exception exception) {
result.setErrorMessage(exception.getMessage());
}
我不断收到错误Unable to calclualte MD5 hash:/file:/storage/sdcard0/DCIM/13161272646580.jpg open failed:ENOENT (No such file or directory)
但是当我浏览我的sd卡目录时,我可以在那里找到图片(图片已创建),并且我已经创建了相关权限。
【问题讨论】:
-
您找到解决方案了吗?
-
我也面临同样的问题。你知道解决办法吗?
-
这里一样,有什么解决办法吗? @just_user ?
-
@osayilgan 检查我的答案,希望它对你有用!