Search code examples
iosobjective-cfile-uploadquickblox

Quickblox uploading a file in custom object


I'm trying to upload a file in a custom object but it won't upload the file. The file in not even uploaded, and the "attachment" field on the db remains null. If I'm trying to send the data without QBCOFile it will upload but the "attachment" field remains null.

my code:

    QBCOCustomObject *object = [QBCOCustomObject customObject];
    object.className = @"Custom";
    [object.fields setObject:@"blue" forKey:@"color"];
    QBCOFile *file = [QBCOFile file];
    file.name = @"Picture";
    file.contentType = @"image/png";
    file.data = UIImagePNGRepresentation(stone.picture);
    [object.fields setObject:file forKey:@"attachment"];

    NSMutableArray *customObjects = [NSMutableArray new];
    [customObjects addObject:object];
    [QBCustomObjects createObjects:customObjects className:@"Custom" delegate:self];

Solution

  • This is a wrong way,

    look at this guide http://quickblox.com/developers/SimpleSample-customObjects-ios#Files

    you need the next:

    1. Create an object of your class with file field
    2. Upload a file to this field