1

I modeled my code after their Mealspotting tutorial but for some reason, I can't see the file saved in the Data Browser. Why is that? Here is my code:

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();
                }
            }
        });
    }
4
  • It's not in the File Storage either Commented Mar 5, 2014 at 0:58
  • How did you save the image file? Could you post the code? Commented Mar 5, 2014 at 1:18
  • "ParseUser.getCurrentUser().put("photo",photoFile); Commented Mar 5, 2014 at 2:04
  • Here's a huge example on saving images to Parse. stackoverflow.com/a/23859786/294884 The thing I'm struggling with the getting the damned bitmap from the camera onActivityResult !! Commented May 25, 2014 at 21:55

1 Answer 1

1

You are just forgetting to save your User object: ParseUser.getCurrentUser().saveEventually();

Sign up to request clarification or add additional context in comments.

10 Comments

why is it saveEventually() and not saveInBackground()?
also, can I still retrieve the files from the User without creating a Photo class?
Just because it's simpler. saveEventually will save your photo, eventually (as soon as it can) :)
Thanks, can you answer my second question too?
Yes, you can. In this case you'll need to create a field for the photo on the user class and associate it to the user object and save it, the same way as the "Photo" class. Are you saving a profile picture?
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.