我想将个人资料图片等图像上传到 Parse 云,并在 Android 登录窗口中同时提供用户名、电子邮件和密码。这可能吗?或者需要为图像上传制作一个单独的表?这是我的新用户保存代码。
ParseUser user = new ParseUser();
Bitmap bitmap = ((BitmapDrawable) registerPic.getDrawable()).getBitmap();
ByteArrayOutputStream stream = new ByteArrayOutputStream();
bitmap.compress(Bitmap.CompressFormat.PNG, 100, stream);
byte[] image = stream.toByteArray();
ParseFile file = new ParseFile("profile.png", image);
file.saveInBackground();
user.setUsername(username);
user.setPassword(pword);
user.put("UserRPassword", repword);
user.setEmail(email);
user.saveInBackground();
user.signUpInBackground(new SignUpCallback() {
@Override
public void done(ParseException e) {
最佳答案
好吧,你已经完成了必要的工作。但您尚未在用户对象中设置该文件。因此,您需要做的是,与其他数据设置一起添加 user.put("profilepic", file);
。
引用Parse Documentation on Files了解更多详情。
关于java - 将图像上传到 Android 中 Parse Cloud 中的 User 表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29872851/