I’ve searched for the past hour for an answer to this. I’m sure i’m just not able to find the answer. I am trying to upload a file then add the file reference to my object.
When I save my object to the datastore and the object is returned the file reference is empty and it is also empty in the console when browsing the object. What am I doing wrong?
Thanks!
`Backendless.shared.fileService.uploadFile(fileName: BackendlessFile.generateFileId(), filePath: BackendlessUser.currentUserId(), content: data, responseHandler: { (backendlessFile) in
DispatchQueue.main.async {
let model = SharedQuilt.init()
model.image = backendlessFile
model.title = self.tfDesignTitle.text
model.detailText = self.tfDetails.text
let dataStore = Backendless.shared.data.of(SharedQuilt.self)
dataStore.save(entity: model, responseHandler: { (sharedQuilt) in
DialogManager.shared.hide()
self.dismiss(animated: true) {
}
}) { (fault) in
DialogManager.shared.hide()
DialogManager.shared.presentAlert(title: "Error", message: fault.message ?? "Something went wrong", actions: [UIAlertAction.init(title: "OK", style: .default, handler: { (action) in
})])
}
}
}) { (fault) in
DialogManager.shared.hide()
DialogManager.shared.presentAlert(title: "Error", message: fault.message ?? "Something went wrong", actions: [UIAlertAction.init(title: "OK", style: .default, handler: { (action) in
})])
}`