Unable to save object - invalid data type for properties

I have a BackendlessFile type property in my Objective-C class. When saving the object after uploading a file to backendless server, I get the error: Unable to save object - invalid data type for properties.
Following is my Objective-C class’s .h file code:

#import <Foundation/Foundation.h>
#import <BackendlessFile.h>
@interface detection_history : NSObject
@property (nonatomic, assign, getter = getObjectId, setter = setObjectId:) NSString *objectId;
@property (nonatomic, strong) NSDate *created;
@property (nonatomic, strong) NSDate *updated;
@property (nonatomic,strong)BackendlessFile *scream_file;
@property (nonatomic,strong)NSString *userObjectId;
@property (nonatomic,strong)NSString *userEmail;
@property (nonatomic,strong)NSString *device_type;
@property (nonatomic,strong)NSString *phone;
@property (nonatomic,strong)NSString *postcode;
@property (nonatomic,strong)NSString *fullname;
@property (nonatomic,strong)NSString *location;
@property (nonatomic,strong)NSString *address;

Following is the file uploading and then saving ‘detection_history’ objective-C code:
The exact error I get is: Unable to save object - invalid data type for properties - scream_file. You can change the property type in developer console.

- (void) saveHistoryOnBackendless:(NSString*)p_strFilePath {
 NSData *data = [[NSFileManager defaultManager] contentsAtPath:p_strFilePath];
 NSString *fileName = [NSString stringWithFormat:@"screams/%0.0f.wav",[[NSDate date] timeIntervalSince1970] ];
 NSLog(@"sending request for saving scream file upload");
 [backendless.fileService upload:fileName content:data response:^(BackendlessFile *fileReturned) {
 BackendlessUser *user = backendless.userService.currentUser;
 detection_history *history = [detection_history new];
 history.scream_file = fileReturned;
 history.userObjectId = user.objectId;
 history.userEmail = user.email;
 history.device_type = @"iOS";
 if([user getProperty:@"phone"]!=nil){
 history.phone = [user getProperty:@"phone"];
 if([user getProperty:@"postcode"]!=nil){
 history.postcode = [user getProperty:@"postcode"];
 NSString *strFullName = [NSString stringWithFormat:@"%@ %@", [user getProperty:@"first_name"], [user getProperty:@"last_name"]];
 history.fullname = strFullName;
 double dLatitude = 0;
 double dLongitude = 0;
 CLLocation* location = [[EMGLocationManager sharedInstance] m_location_gps];
 if (location != nil) {
 dLatitude = location.coordinate.latitude;
 dLongitude = location.coordinate.longitude;
 NSString *strLocation = [NSString stringWithFormat:@"(%.4f, %.4f)", dLatitude, dLongitude];
 history.location = strLocation;
 id<IDataStore> dataStore = [backendless.persistenceService of:[detection_history class]];
 [dataStore save:history response:^(id response) {
 NSLog(@"history saved");
 } error:^(Fault * error) {
 NSLog(@"detection history couldn't be saved: %@",[error message]);
 } error:^(Fault *error) {
 NSLog(@"File couldn't be uploaded: %@",[error message]);

Attached is the snapshot of detection_history table schema in backendless.

I am unable to attach screenshot of the schema.

scream_file is a ‘File Reference’ type column

Hi Chanchal,

What is the data type of the scream_file column in your table?

Please provide your appId here or to support@backendless.com. We need to reproduce this issue with your data.

The app is: F843AD08-5CB2-8C59-FFC2-7705A83DC200

The data type of the scream_file column, as already mentioned, is File Reference’.
I have solved the problem by making my scream_file property of NSString type instead of BackendlessFile type and have assigned it with uploaded file’s URL string and it did all good.
Though I searched for this particular thing in all the documentation provided, but couldn’t find.

Following is short code to make you understand how the problem resolved.
timeIntervalSince1970] ];

    [backendless.fileService upload:fileName content:data response:^(BackendlessFile *fileReturned) {
        BackendlessUser *user = backendless.userService.currentUser;
        detection_history *history = [detection_history new];
        history.scream_file = fileReturned.fileURL;
        history.userObjectId = user.objectId;
//After that I am saving this history object, and it saved successfully.
     error:^(Fault *error) {
        NSLog(@"File couldn't be uploaded: %@",[error detail]);

It is little off-disscussion comment but related to the code above for file uploading. Why do I have to send file name?? I want to save several files on server every other second and there are many users of the app. It is dangerous, because due to many users, it can be possible that users’ file name matches and therefore, cannot be uploaded on server in same folder. I, therefore, request you to devise some way in the API so that we need to provide file name along with the data. You can use Parse’s good example.

But the file has to have a name, that’s how the files are identified. How would we save it on disk in case you don’t specify a name?

You are right, a file has to have some name; but it should be decided by backendless not the API users. See how Parse had provided:

NSData *imageData = UIImagePNGRepresentation(profileImage);
PFFile *imageFile = [PFFile fileWithName:@"Profileimage.png" data:imageData];
[imageFile saveInBackgroundWithBlock:^(BOOL succeeded, NSError *error) {
    if (!error) {}];

r Here the file name is Profileimage.png, and if you call this code saveral times, it will execute without errors in file saving i.e. regardless of the fact the file with the same name exists on server or not. What parse does is saves the file with its own internal name. This has to be done with backendless too.