I am using swift with the Parse Framework (1.6.2). I am storing data into the local datastorage. The data consists of a few strings and an image. This image will be stored within a PfFile and then will be added to the PfObject.
Now I wondered why the image doesn't get saved until I noticed I needed to call the save() method of the PFFile. Problem is that the Image then seems to be uploaded to Parse which I don't want. I want it to be stored on the local device..
Is there a solution for this?
Thanks
Edit:
The code works like this:
var spot = PFObject(className: "Spot")
let imageData = UIImageJPEGRepresentation(spotModel.getPhoto(), 0.05)
let imageFile = PFFile(name:"image.jpg", data:imageData)
spotObj.setObject(spotModel.getCategory(), forKey: "category")
spotObj.setObject(imageFile, forKey: "photo")
//if I simply would do this, the PFObject will be saved into the local datastorage, but the image won't be saved
spotObj.pin()
//if I do this, the image will be saved also BUT it won't be saved into the local data storage but will be uploaded to parse
imageFile.save()
spotObj.pin()
Okay, take a look here Save eventually on PFObject with PFFile (Parse Local Datastore)?. One this is for sure, if you call save on PFFile it will get save to online datastore. So you should use PFFile.save(). I think best option for you is to save the file in some folder. locally and save that path in PFObject. Parse documentation just say this
It recursively calls .pin() on the other objects in your main PFObject. But if you take a look at PFFile API doc it doest have a .pin() which means it doesn't support saving PFFile to local datastore. So I would say you should save them in some directory and save path in your PFObject.
Update