function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
bdPeterbdPeter 

Can SmartStore soup accept large base64 string as a field in record?

In my hybrid app I am creating Attachment records in SmartStore (which later at the user's convenience can be uploaded to Salesforce). This is all working fine with the MockSmartStore. However, with the actual SmartStore on a device I am getting an NPObject exception (see 'Body' field in trace below).

 

Can the SmartStore handle a large string containing a base64 string?

 

Thanks

Peter

 

D/CordovaLog( 2137): file:///android_asset/app/scripts/vendor/cordova.force.js: Line 479 : SmartStore.registerSoup: 'smA
ttachments_a00i0000005SH72AAG' indexSpecs: [{"path":"ParentId","type":"string"},{"path":"TimeStamp","type":"integer"}]
D/CordovaLog( 2137): file:///android_asset/app/scripts/controllers/controllers.js: Line 747 : onAcceptAttachments: attac
hments soup registered, issuing write for attachments record
D/CordovaLog( 2137): file:///android_asset/app/scripts/controllers/controllers.js: Line 748 : onAcceptAttachments: {"Tim
eStamp":1377020402902,"Name":"1377020392246.jpg","Description":"","IsPrivate":false,"ParentId":"003i000000CsLkpAAF","Con
tentType":"image/jpeg","Body":"/9j/4AAQSkZJRgABAQAAAQABAAD/2wBDAAIBAQEBAQIBAQECAgICAgQDAgICAgUEBAMEBgUGBgYF\nBgYGBwkIBgc
JBwYGCAsICQoKCgoKBggLDAsKDAkKCgr/2wBDAQICAgICAgUDAwUKBwYHCgoKCgoK\nCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKC
goKCgr/wAARCAHgAoADASIA\nAhEBAxEB/8QAHwAAAQUBAQEBAQEAAAAAAAAAAAECAwQFBgcICQoL/8QAtRAAAgEDAwIEAwUFBAQA\nAAF9AQIDAAQRBRIhM
UEGE1FhByJxFDKBkaEII0KxwRVS0fAkM2JyggkKFhcYGRolJicoKSo0NTY3\nODk6Q0RFRkdISUpTVFVWV1hZWmNkZWZnaGlqc3R1dnd4eXqDhIWGh4iJipK
TlJWWl5iZmqKjpKWm\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evWqsayLIVVyRjgmtqSzUKRyfRSPrVU2cqEsqDaR260nUk5XmOMEl\noYuqbhEwJ5x2rkYgH1yZmJxjaOO1drqdkDE6kkEc5HeuTtdOaW/luFbkcMD9amUeZ
tpFx
D/CordovaLog( 2137): file:///android_asset/app/components-min/angular/angular.js: Line 5754 : Error: Error calling metho
d on NPObject.
D/CordovaLog( 2137): at androidExec (file:///android_asset/app/scripts/vendor/cordova.js:863:48)
D/CordovaLog( 2137): at file:///android_asset/app/scripts/vendor/cordova.force.js:196:16
D/CordovaLog( 2137): at file:///android_asset/app/scripts/vendor/cordova.force.js:538:9
D/CordovaLog( 2137): at Object.upsertSoupEntries (file:///android_asset/app/scripts/vendor/cordova.force.js:531:9)
D/CordovaLog( 2137): at Object.writeRecords (file:///android_asset/app/scripts/services/services.js:1874:22)
D/CordovaLog( 2137): at file:///android_asset/app/scripts/controllers/controllers.js:751:31
D/CordovaLog( 2137): at file:///android_asset/app/components-min/angular/angular.js:6846:59
D/CordovaLog( 2137): at file:///android_asset/app/components-min/angular/angular.js:6846:59
D/CordovaLog( 2137): at file:///android_asset/app/components-min/angular/angular.js:6883:26
D/CordovaLog( 2137): at Object.$eval (file:///android_asset/app/components-min/angular/angular.js:8057:28)
D/CordovaLog( 2137): file:///android_asset/app/scripts/services/services.js: Line 364 : AttachHub.reportError: {}

Best Answer chosen by Admin (Salesforce Developers) 
bdPeterbdPeter

Hi Gaurav, thanks for your suggestion. As a result I went back and had another detailed look this morning. As it turns out I should have investigated better before I posted. The base64 string is accepted just fine. The NP Object exception was caused by the integer timestamp in the record exceeding maximum integer value. I was fooled by it working just fine in the MockSmartstore.

 

I don't t regret posting though because I learned from akhilesh about the 1MB maximum blob size in SmartStore. I like the idea of storing potential sensitive documents temporary in SmartStore (before they are uploaded to SF) due to its encryption and logout destruction. Ideally though the attachments can have the same maximum size as in Salesforce. I am looking forward to the file storage solutions that akhilesh mentioned.

 

Peter

All Answers

akhilesh_sfdcakhilesh_sfdc
How big is your attachment file? One known limitation of SQLite on Android is the 1MB size limit, and this could be the issue that you are encountering. Reference: http://stackoverflow.com/questions/5406429/cursor-size-limit-in-android-sqlitedatabase

We are currently working on some file storage solutions to handle such situations.
bdPeterbdPeter

The file size is nowhere near 1MB, just 93110 bytes (see trace below). Thanks for pointing out this 1MB limitation though. In this case, however, the limit does not play a role.

 

Peter

 

I/Web Console( 1827): RequestDoc LaunchCameraApp result.statuscode=1 at file:///android_asset/app/scripts/controllers/co
ntrollers.js:666
D/CordovaLog( 1827): file:///android_asset/app/scripts/controllers/controllers.js: Line 692 : ---------------Body base64
size=93110
I/Web Console( 1827): ---------------Body base64 size=93110 at file:///android_asset/app/scripts/controllers/controllers
.js:692
V/PhoneStatusBar( 1276): setLightsOn(true)
D/LockChecker:run( 1827): isLocked:true elapsedSinceLastActivity:20 timeout:0
D/LockChecker:run( 1827): isLocked:true elapsedSinceLastActivity:40 timeout:0
I/SmartStorePlugin.execute( 1827): action: pgRegisterSoup, jsVersion: 2.0.0
W/SmartStorePlugin.execute( 1827): is being called by js from older sdk, jsVersion: 2.0.0, nativeVersion: 2.0.1
I/SmartStorePlugin.execute( 1827): action: pgQuerySoup, jsVersion: 2.0.0
W/SmartStorePlugin.execute( 1827): is being called by js from older sdk, jsVersion: 2.0.0, nativeVersion: 2.0.1
I/SmartSqlHelper.convertSmartSql( 1827): smart sql = SELECT {smUpdates_a00i0000005SH72AAG:_soup} FROM {smUpdates_a00i00
00005SH72AAG} WHERE {smUpdates_a00i0000005SH72AAG:_recordId} = ? ORDER BY {smUpdates_a00i0000005SH72AAG:_recordId} ASC
I/SmartSqlHelper.convertSmartSql( 1827): sql = SELECT TABLE_2.soup FROM TABLE_2 WHERE TABLE_2_0 = ? ORDER BY TABLE_2_0
ASC
I/SmartSqlHelper.convertSmartSql( 1827): smart sql = SELECT {smUpdates_a00i0000005SH72AAG:_soup} FROM {smUpdates_a00i00
00005SH72AAG} WHERE {smUpdates_a00i0000005SH72AAG:_recordId} = ? ORDER BY {smUpdates_a00i0000005SH72AAG:_recordId} ASC
I/SmartSqlHelper.convertSmartSql( 1827): sql = SELECT TABLE_2.soup FROM TABLE_2 WHERE TABLE_2_0 = ? ORDER BY TABLE_2_0
ASC
I/SmartStorePlugin.execute( 1827): action: pgCloseCursor, jsVersion: 2.0.0
W/SmartStorePlugin.execute( 1827): is being called by js from older sdk, jsVersion: 2.0.0, nativeVersion: 2.0.1
I/SmartStorePlugin.execute( 1827): action: pgUpsertSoupEntries, jsVersion: 2.0.0
W/SmartStorePlugin.execute( 1827): is being called by js from older sdk, jsVersion: 2.0.0, nativeVersion: 2.0.1
I/SmartStorePlugin.execute( 1827): action: pgRegisterSoup, jsVersion: 2.0.0
W/SmartStorePlugin.execute( 1827): is being called by js from older sdk, jsVersion: 2.0.0, nativeVersion: 2.0.1
D/CordovaLog( 1827): file:///android_asset/app/scripts/vendor/cordova.force.js: Line 479 : SmartStore.registerSoup: 'smU
pdates_a00i0000005SH72AAG' indexSpecs: [{"path":"_recordId","type":"string"},{"path":"_numAtt","type":"integer"},{"path"
:"_numUpdt","type":"integer"}]
I/Web Console( 1827): SmartStore.registerSoup: 'smUpdates_a00i0000005SH72AAG' indexSpecs: [{"path":"_recordId","type":"s
tring"},{"path":"_numAtt","type":"integer"},{"path":"_numUpdt","type":"integer"}] at file:///android_asset/app/scripts/v
endor/cordova.force.js:479
D/CordovaLog( 1827): file:///android_asset/app/scripts/vendor/cordova.force.js: Line 504 : SmartStore.querySoup: 'smUpda
tes_a00i0000005SH72AAG' indexPath: _recordId
I/Web Console( 1827): SmartStore.querySoup: 'smUpdates_a00i0000005SH72AAG' indexPath: _recordId at file:///android_asset
/app/scripts/vendor/cordova.force.js:504
D/CordovaLog( 1827): file:///android_asset/app/scripts/vendor/cordova.force.js: Line 582 : closeCursor: 8
I/Web Console( 1827): closeCursor: 8 at file:///android_asset/app/scripts/vendor/cordova.force.js:582
D/CordovaLog( 1827): file:///android_asset/app/scripts/vendor/cordova.force.js: Line 479 : SmartStore.registerSoup: 'smA
ttachments_a00i0000005SH72AAG' indexSpecs: [{"path":"ParentId","type":"string"},{"path":"TimeStamp","type":"integer"}]
I/Web Console( 1827): SmartStore.registerSoup: 'smAttachments_a00i0000005SH72AAG' indexSpecs: [{"path":"ParentId","type"
:"string"},{"path":"TimeStamp","type":"integer"}] at file:///android_asset/app/scripts/vendor/cordova.force.js:479
I/SmartStorePlugin.execute( 1827): action: pgUpsertSoupEntries, jsVersion: 2.0.0
W/SmartStorePlugin.execute( 1827): is being called by js from older sdk, jsVersion: 2.0.0, nativeVersion: 2.0.1
D/CordovaLog( 1827): file:///android_asset/app/components-min/angular/angular.js: Line 5754 : Error: Error calling metho
d on NPObject.
D/CordovaLog( 1827): at androidExec (file:///android_asset/app/scripts/vendor/cordova.js:863:48)
D/CordovaLog( 1827): at file:///android_asset/app/scripts/vendor/cordova.force.js:196:16
D/CordovaLog( 1827): at file:///android_asset/app/scripts/vendor/cordova.force.js:538:9
D/CordovaLog( 1827): at Object.upsertSoupEntries (file:///android_asset/app/scripts/vendor/cordova.force.js:531:9)
D/CordovaLog( 1827): at Object.writeRecords (file:///android_asset/app/scripts/services/services.js:1879:22)
D/CordovaLog( 1827): at file:///android_asset/app/scripts/controllers/controllers.js:744:31
D/CordovaLog( 1827): at file:///android_asset/app/components-min/angular/angular.js:6846:59
D/CordovaLog( 1827): at file:///android_asset/app/components-min/angular/angular.js:6846:59
D/CordovaLog( 1827): at file:///android_asset/app/components-min/angular/angular.js:6883:26
D/CordovaLog( 1827): at Object.$eval (file:///android_asset/app/components-min/angular/angular.js:8057:28)
E/Web Console( 1827): Error: Error calling method on NPObject.
E/Web Console( 1827): at androidExec (file:///android_asset/app/scripts/vendor/cordova.js:863:48)
E/Web Console( 1827): at file:///android_asset/app/scripts/vendor/cordova.force.js:196:16
E/Web Console( 1827): at file:///android_asset/app/scripts/vendor/cordova.force.js:538:9
E/Web Console( 1827): at Object.upsertSoupEntries (file:///android_asset/app/scripts/vendor/cordova.force.js:531:9)
E/Web Console( 1827): at Object.writeRecords (file:///android_asset/app/scripts/services/services.js:1879:22)
E/Web Console( 1827): at file:///android_asset/app/scripts/controllers/controllers.js:744:31
E/Web Console( 1827): at file:///android_asset/app/components-min/angular/angular.js:6846:59
E/Web Console( 1827): at file:///android_asset/app/components-min/angular/angular.js:6846:59
E/Web Console( 1827): at file:///android_asset/app/components-min/angular/angular.js:6883:26
E/Web Console( 1827): at Object.$eval (file:///android_asset/app/components-min/angular/angular.js:8057:28) at file:
///android_asset/app/components-min/angular/angular.js:5754
D/CordovaLog( 1827): file:///android_asset/app/scripts/services/services.js: Line 364 : AttachHub.reportError: {}
I/Web Console( 1827): AttachHub.reportError: {} at file:///android_asset/app/scripts/services/services.js:364
E/SurfaceFlinger( 794): ro.sf.lcd_density must be defined as a build property

Gaurav KheterpalGaurav Kheterpal

Someone had reported a similar isuse on this thread and was able to get it working - http://boards.developerforce.com/t5/Mobile/Encountering-issues-when-I-run-Salesforce-Hybrid-sample-app-quot/m-p/665592

 

You might want to try this out.

 

Regards,
Gaurav

bdPeterbdPeter

Hi Gaurav, thanks for your suggestion. As a result I went back and had another detailed look this morning. As it turns out I should have investigated better before I posted. The base64 string is accepted just fine. The NP Object exception was caused by the integer timestamp in the record exceeding maximum integer value. I was fooled by it working just fine in the MockSmartstore.

 

I don't t regret posting though because I learned from akhilesh about the 1MB maximum blob size in SmartStore. I like the idea of storing potential sensitive documents temporary in SmartStore (before they are uploaded to SF) due to its encryption and logout destruction. Ideally though the attachments can have the same maximum size as in Salesforce. I am looking forward to the file storage solutions that akhilesh mentioned.

 

Peter

This was selected as the best answer