想通过手机拍照然后将图片存储到AVFile中,但是在文件管理有中图片,但点击url打开的图片报错
public void storePhoto(String fileName, String path) {
Log.d("Notification_photo", "进入storePhoto方法");
try {
AVFile avFile = AVFile.withAbsoluteLocalPath(fileName, path);
avFile.saveInBackground().subscribe(new Observer() {
public void onSubscribe(Disposable disposable) {
Log.d("Notification_photo", "onSubscribe");
}
public void onNext(AVFile file) {
Log.d("Notification_photo", "onNext");
Log.d("文件保存完成。objectId:", file.getObjectId());
SharedPreferences.Editor editor = getSharedPreferences("user", MODE_PRIVATE).edit();
editor.putString("userImgObjectId", file.getObjectId());
editor.apply();
}
public void onError(Throwable throwable) {
// 保存失败,可能是文件无法被读取,或者上传过程中出现问题
Log.d("Notification_photo", "onError");
}
public void onComplete() {
Log.d("Notification_photo", "onError");
}
});
AVObject user = new AVObject("user");
user.add("userImg", avFile);
user.save();
} catch (FileNotFoundException e) {
e.printStackTrace();
}