Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Save a picture of a signature to a file in Rhodes on Android

I am trying to implement signature capture using Rhodes targeting an Android tab. I have managed to get the canvas and scribble on it. But am unable to save the signature at a desired location. The signature_uri takes the default location as db/db-files/Image-XXXXXX.png.

This was the code in the sample example:

def signature_callback if @params['status'] == 'ok'   #create signature record in the DB   signature = SignatureUtil.new({'signature_uri'=>@params['signature_uri']})   signature.save   puts "new Signature object: " + signature.inspect end 

In the console I got:

APP| RHO serve: /app/Settings/signature_callback I/APP     (  801): I 01/26/2012 11:36:20:236 0000032e                  APP| Params: {"status"=>"ok", "signature_uri"=>"db/db-files/Image_20120126113618375.png", "rho_callback"=>"1"} I/APP     (  801): I 01/26/2012 11:36:20:238 0000032e                  APP| *******************ok**************** I/APP     (  801): I 01/26/2012 11:36:20:238 0000032e                  APP| %%%%%%%%%%%%%%%%%db/db-files/Image_20120126113618375.png%%%%%%%%%%% I/APP     (  801): I 01/26/2012 11:36:20:239 0000032e                  APP| App error: can't convert Symbol into Integer I/APP     (  801):  lib/rhom/rhom_object_factory.rb:67:in `[]' I/APP     (  801): lib/rhom/rhom_object_factory.rb:67:in `initialize' I/APP     (  801): apps/app/Settings/controller.rb:34:in `new' I/APP     (  801): apps/app/Settings/controller.rb:34:in `signature_callback' I/APP     (  801): lib/rho/rhocontroller.rb:91:in `serve' I/APP     (  801): lib/rho/rhoapplication.rb:209:in `serve' I/APP     (  801): lib/rho/rho.rb:822:in `serve' I/APP     (  801): E 01/26/2012 11:36:20:248 00000321                  Net| Request failed. HTTP Code: 500 returned. HTTP Response:         <html> I/APP     (  801):             <head> I/APP     (  801):                 <meta name="viewport" content="width=320"/> I/APP     (  801):             </head> I/APP     (  801):             <body> I/APP     (  801):                 <h2>Server Error</h2> I/APP     (  801):                 <p> I/APP     (  801): Error: can't convert Symbol into Integer<br/>Trace: <br/ 

Now instead of this database storage, I want to save it in a desired location. Please share your views.

like image 302
Vikas Avatar asked Jan 26 '12 06:01

Vikas


1 Answers

have you checked out this page: http://docs.rhomobile.com/rhodes/device-caps#file-system-access ? It looks to me like you need to save the image to the DB and use the Rho::RhoApplication::get_blob_path(image.image_uri) method to open the file. Then you should be able to use the file system API to create a new file and write the contents of the image to it wherever you choose.

like image 181
corneliusk Avatar answered Sep 19 '22 13:09

corneliusk