Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-1656] API inconsistency: TiBlob has 'length' property on Android, 'size' on iOS

GitHub Issuen/a
Resolution Date2012-05-03T15:47:23.000+0000
Affected Version/sn/a
Fix Version/sRelease 2.1.0
ReporterBrion Vibber
AssigneeNolan Wright


In StatusNet Mobile, I'm trying to get the byte size of a blob I've read from a file when passing a saved photo from one context to another. The undocumented TiBlob type has a lot of differences in its interface between the iOS and Android implementations, and it's hitting here...

On Android there's a 'length' property:

public int getLength() {
    switch (type) {
        case TYPE_FILE:
            return (int) ((TiBaseFile)data).getNativeFile().length();
        case TYPE_DATA:
        case TYPE_IMAGE:
            return ((byte[])data).length;
            // this is probably overly expensive.. is there a better way?
            return getBytes().length;

But on iOS, there's a 'size' property:

-(NSInteger)size {

[self ensureImageLoaded];
if (image!=nil)
    return image.size.width * image.size.height;
switch (type)
    case TiBlobTypeData:
        return [data length];
    case TiBlobTypeFile:
        NSFileManager *fm = [NSFileManager defaultManager];
        NSError *error = nil; 
        NSDictionary * resultDict = [fm attributesOfItemAtPath:path error:&error];
        id result = [resultDict objectForKey:NSFileSize];
        if (error!=NULL)
            return 0;
        return [result intValue];
return 0;


They also don't have matching behavior for image blobs: Android appears to return the byte size of whatever raw data the image is using (is this source file? uncompressed? what bit depth?), while on iOS it returns the number of pixels in the image. (Shouldn't make a difference in this case though, since I'm reading straight from a saved temporary file.)

Referencing my previous bug on the missing API documentation for the Blob type on mobile:

https://appcelerator.lighthouseapp.com/projects/32238/tickets/1580-titaniumblob-tiblob-missing-from-mobile-api-documentation"> https://appcelerator.lighthouseapp.com/projects/32238/tickets/1580-...

Note that the Desktop docs do have documentation for the Blob type there:

https://developer.appcelerator.com/apidoc/desktop/latest/Titanium.Blob-object"> https://developer.appcelerator.com/apidoc/desktop/latest/Titanium.B...

Desktop's blob type has a 'length' property, matching the Android implementation (though I'm uncertain whether there are image blobs on Desktop, and it doesn't say how it would return a length for those).

Assigning to StatusNet's support contact.


  1. Stephen Tramer 2012-05-03

    Fixed in master ( at some point. Resolving.
  2. Lee Morris 2017-03-07

    Closing ticket due to time passed.

JSON Source