Parse.com文件保存Android不工作
我根据Mealspotting教程对代码进行建模,但由于某些原因,我无法看到保存在数据浏览器中的文件。为什么呢?这是我的密码:Parse.com文件保存Android不工作,android,image,parse-platform,Android,Image,Parse Platform,我根据Mealspotting教程对代码进行建模,但由于某些原因,我无法看到保存在数据浏览器中的文件。为什么呢?这是我的密码: private void saveScaledPhoto(byte[] data) { // Resize photo from camera byte array Bitmap snypImage = BitmapFactory.decodeByteArray(data, 0, data.length); Bitmap
private void saveScaledPhoto(byte[] data) {
// Resize photo from camera byte array
Bitmap snypImage = BitmapFactory.decodeByteArray(data, 0, data.length);
Bitmap snypImageScaled = Bitmap.createScaledBitmap(snypImage, 200, 200
* snypImage.getHeight() / snypImage.getWidth(), false);
// Override Android default landscape orientation and save portrait
Matrix matrix = new Matrix();
matrix.postRotate(90);
Bitmap rotatedScaledMealImage = Bitmap.createBitmap(snypImageScaled, 0,
0, snypImageScaled.getWidth(), snypImageScaled.getHeight(),
matrix, true);
ByteArrayOutputStream bos = new ByteArrayOutputStream();
rotatedScaledMealImage.compress(Bitmap.CompressFormat.JPEG, 100, bos);
byte[] scaledData = bos.toByteArray();
// Save the scaled image to Parse
photoFile = new ParseFile("snyp.jpg", scaledData);
photoFile.saveInBackground(new SaveCallback() {
public void done(ParseException e) {
if (e == null) {
ParseUser.getCurrentUser().put("photo",photoFile);
Log.d("save status",photoFile.getName() + " is saved!");
} else {
Toast.makeText(getActivity(),
"Error saving: " + e.getMessage(),
Toast.LENGTH_LONG).show();
}
}
});
}
您只是忘记保存用户对象:
ParseUser.getCurrentUser().saveFinally()代码>它不在文件存储器中。您是如何保存图像文件的?你能发布代码吗?“ParseUser.getCurrentUser().put(“photo”,photoFile);这里是一个保存要解析的图像的巨大示例。我正在努力从activityResult上的摄像头获取该死的位图!!为什么它是savefinally()而不是saveInBackground())?另外,我是否可以在不创建照片类的情况下从用户检索文件?仅仅因为它更简单。SaveFinally最终将保存您的照片(尽快):)谢谢,你能回答我的第二个问题吗?是的,你能。在这种情况下,你需要在用户类上为照片创建一个字段,并将其与用户对象关联并保存它,与“照片”类的方式相同。你正在保存个人资料图片吗?