parse-server icon indicating copy to clipboard operation
parse-server copied to clipboard

Saving images to MongoDB using Parse code

Open fletcher100 opened this issue 10 years ago • 2 comments

Is there a way to save images to MongoDB through parse code just as you can with a string value? The images I am trying to save using my parse code are not showing up in MongoLab like my string values are.

I have read about something called GridFs is this what I am supposed to use for this task?

This example code from the Parse documentation does not seem to save an image file to the database.

let imageData = UIImagePNGRepresentation(image) let imageFile = PFFile(name:"image.png", data:imageData)

var userPhoto = PFObject(className:"UserPhoto") userPhoto["imageName"] = "My trip to Hawaii!" userPhoto["imageFile"] = imageFile userPhoto.saveInBackground()

Thank you for any guidance.

fletcher100 avatar Feb 09 '16 06:02 fletcher100

That code should result in an image saved in GridStore. Can you tell us what error messages you are getting? You can see error messages on the server by running the server with VERBOSE=1

drew-gross avatar Feb 09 '16 17:02 drew-gross

I figured out the answer to my question. Thank you anyways, drew-gross.

fletcher100 avatar Feb 10 '16 05:02 fletcher100