{ "id": "62288", "key": "TIMOB-1656", "fields": { "issuetype": { "id": "1", "description": "A problem which impairs or prevents the functions of the product.", "name": "Bug", "subtask": false }, "project": { "id": "10153", "key": "TIMOB", "name": "Titanium SDK/CLI", "projectCategory": { "id": "10100", "description": "Titanium and related SDKs used in application development", "name": "Client" } }, "fixVersions": [ { "id": "13271", "description": "Release 2.1.0", "name": "Release 2.1.0", "archived": false, "released": true, "releaseDate": "2012-06-29" } ], "resolution": { "id": "1", "description": "A fix for this issue is checked into the tree and tested.", "name": "Fixed" }, "resolutiondate": "2012-05-03T15:47:23.000+0000", "created": "2011-04-15T02:58:35.000+0000", "priority": { "name": "Medium", "id": "3" }, "labels": [ "core" ], "versions": [], "issuelinks": [], "assignee": { "name": "nwright", "key": "nwright", "displayName": "Nolan Wright", "active": false, "timeZone": "America/Los_Angeles" }, "updated": "2017-03-07T18:19:56.000+0000", "status": { "description": "The issue is considered finished, the resolution is correct. Issues which are closed can be reopened.", "name": "Closed", "id": "6", "statusCategory": { "id": 3, "key": "done", "colorName": "green", "name": "Done" } }, "components": [ { "id": "10202", "name": "Android", "description": "Android Platform" } ], "description": "{html}

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

\n

On Android there's a 'length' property:

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

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

\n

-(NSInteger)size {

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

}

\n

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

\n

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

\n

\nhttps://appcelerator.lighthouseapp.com/projects/32238/tickets/1580-...

\n

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

\n

\nhttps://developer.appcelerator.com/apidoc/desktop/latest/Titanium.B...

\n

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

\n

Assigning to StatusNet's support contact.

{html}", "attachment": [], "flagged": false, "summary": "API inconsistency: TiBlob has 'length' property on Android, 'size' on iOS", "creator": { "name": "brionvibber", "key": "brionvibber", "displayName": "Brion Vibber", "active": true, "timeZone": "America/Los_Angeles" }, "subtasks": [], "reporter": { "name": "brionvibber", "key": "brionvibber", "displayName": "Brion Vibber", "active": true, "timeZone": "America/Los_Angeles" }, "environment": null, "comment": { "comments": [ { "id": "193638", "author": { "name": "stephentramer", "key": "stephentramer", "displayName": "Stephen Tramer", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Fixed in master (2.1.0.848d711) at some point. Resolving.", "updateAuthor": { "name": "stephentramer", "key": "stephentramer", "displayName": "Stephen Tramer", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2012-05-03T15:47:23.000+0000", "updated": "2012-05-03T15:47:23.000+0000" }, { "id": "409538", "author": { "name": "lmorris", "key": "lmorris", "displayName": "Lee Morris", "active": false, "timeZone": "America/Los_Angeles" }, "body": "Closing ticket due to time passed.", "updateAuthor": { "name": "lmorris", "key": "lmorris", "displayName": "Lee Morris", "active": false, "timeZone": "America/Los_Angeles" }, "created": "2017-03-07T18:19:56.000+0000", "updated": "2017-03-07T18:19:56.000+0000" } ], "maxResults": 2, "total": 2, "startAt": 0 } } }