Java 如何在Parse.com中存储和接收配置文件图片?

Java 如何在Parse.com中存储和接收配置文件图片?,java,android,parsing,parse-platform,Java,Android,Parsing,Parse Platform,我是parse.com的新手。我已经搜索了几个小时如何为用户创建一张个人资料图片,但没有结果。我知道如何上传图片到Parse.com,但我不知道如何接收它 这是我上传图像的方式: // Save new user data into Parse.com Data Storage ParseUser user = new ParseUser(); user.setUsername(usernametxt);

我是parse.com的新手。我已经搜索了几个小时如何为用户创建一张个人资料图片,但没有结果。我知道如何上传图片到Parse.com,但我不知道如何接收它

这是我上传图像的方式:

  // Save new user data into Parse.com Data Storage
                ParseUser user = new ParseUser();
                user.setUsername(usernametxt);
                user.setPassword(passwordtxt);
                ByteArrayOutputStream stream = new ByteArrayOutputStream();
                // Compress image to lower quality scale 1 - 100
                photo.compress(Bitmap.CompressFormat.PNG, 100, stream);
                byte[] image = stream.toByteArray();

                // Create the ParseFile
                ParseFile file = new ParseFile(usernametxt + ".png", image);
                // Upload the image into Parse Cloud
                file.saveInBackground();

                // Create a New Class called "ImageUpload" in Parse
                ParseObject imgupload = new ParseObject("ImageUpload");

                // Create a column named "ImageName" and set the string
                imgupload.put("ImageName", usernametxt);

                // Create a column named "ImageFile" and insert the image
                imgupload.put("ImageFile", file);

                // Create the class and the columns
                imgupload.saveInBackground();

                // Show a simple toast message
                Toast.makeText(RegisterActivity.this, "Image Uploaded",
                        Toast.LENGTH_SHORT).show();

                user.signUpInBackground(new SignUpCallback() {
                   public void done(ParseException e) {
                        if (e == null) {
                            // Show a simple Toast message upon successful registration


                            Intent intent = new Intent(
                                    RegisterActivity.this,
                                    Welcome.class);
                            startActivity(intent);
                            finish();
                        } else {
                            Toast.makeText(getApplicationContext(),
                                   "Sign up Error", Toast.LENGTH_LONG)
                                    .show();
                        }
                    }
               });
           }

        }
这就是我接收图像的方式(不工作,导致异常): ParseQuery=ParseQuery.getQuery(“ImageUpload”); query.whereEqualTo(“ImageName”,currentUser.getUsername()); getFirstInBackground(新的GetCallback(){

如果有人会看看代码,并试图给我一个线索,我做错了,这将非常有帮助我


对不起,我的英语很差。

保存到Parse-只需调用ParseUser表而不是ParseObject表

Bitmap bitmapImage = ((BitmapDrawable) profilepic.getDrawable()).getBitmap(); // profile pic is the imageview
ByteArrayOutputStream stream = new ByteArrayOutputStream();
                    bitmapImage.compress(Bitmap.CompressFormat.JPEG, 40, stream);

                    byte[] byteArray = stream.toByteArray();

                    ParseFile file = new ParseFile("image.png", byteArray);

                    ParseObject Images = new ParseObject("Images");

                    Images.put("profilepic", file);
                    Images.put("username", Username);

                    Images.saveInBackground(new SaveCallback() {
                        @Override
                        public void done(ParseException e) {
                            if (e == null) {
                                Log.i("AppInfo", "Profile pic success");

                            } else {
                                Log.i("AppInfo", "Profile pic FAIL");
                            }
                        }
                    });
从解析中检索

ParseQuery<ParseUser> imageQuery = new ParseUser.getQuery();
 imageQuery.whereEqualTo("objectId",ParseUser.getCurrentUser().getObjectId());
    imageQuery.findInBackground(new FindCallback<ParseObject>()
    {
        @Override
        public void done(List<ParseUser> users,ParseException e)
        {
            for(ParseUser user : users)
            {
                ParseFile UserProPicFile = object.getParseFile("ImageColumnName");
                byte[] byteArray = new byte[0];

                byteArray = UserProPicFile.getData();
                Bitmap ProselectBit = BitmapFactory.decodeByteArray(byteArray,0,byteArray.length); //Bitmap with [rofile picture
            }
        }
    });
ParseQuery imageQuery=new ParseUser.getQuery();
imageQuery.whereEqualTo(“objectId”,ParseUser.getCurrentUser().getObjectId());
findInBackground(新的FindCallback()
{
@凌驾
public void done(列出用户,parsee异常)
{
for(解析用户:用户)
{
ParseFile UserProPicFile=object.getParseFile(“ImageColumnName”);
byte[]byteArray=新字节[0];
byteArray=UserProPicFile.getData();
位图ProselectBit=BitmapFactory.decodeByteArray(byteArray,0,byteArray.length);//带有[rofile picture]的位图
}
}
});
我希望这有帮助

ParseQuery<ParseUser> imageQuery = new ParseUser.getQuery();
 imageQuery.whereEqualTo("objectId",ParseUser.getCurrentUser().getObjectId());
    imageQuery.findInBackground(new FindCallback<ParseObject>()
    {
        @Override
        public void done(List<ParseUser> users,ParseException e)
        {
            for(ParseUser user : users)
            {
                ParseFile UserProPicFile = object.getParseFile("ImageColumnName");
                byte[] byteArray = new byte[0];

                byteArray = UserProPicFile.getData();
                Bitmap ProselectBit = BitmapFactory.decodeByteArray(byteArray,0,byteArray.length); //Bitmap with [rofile picture
            }
        }
    });