Adding BackendlessFile Reference to Object in iOS

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
                
            })])
        }`

Got it sorted. Changed the image from backendless file to string and then saved the backendless fileUrl which is a string to the db instead of referencing a file

Hi, Chris.
Internal ticket BKNDLSS-20050 was created. We’ll investigate this problem.

Your workaround is correct, you always can work with direct file’s URL.

Regards,
Andrii.

Hello Chris,
Issue has been fix in version 5.6.5 of Swift-SDK. Please check and verify whether you can receive the BackendlessFile object correctly.

Regards,
Olha