Voting: 
Vote up!
0 Votes
1 Replies
Unanswered

How to return byte[] from FFI?

Question asked by Ganesh kelam on Feb 22, 2017 07:31 EST

I am developing a camera FFI plugin for Kony on Android environment. In this FFI, I have a method to return captured image as byte[] i.e rawBytes. Here is my FFI method code   public JSONObject getImageRawBytes(String imageID) { byte[] result = null; JSONObject jObject = null;   // ImageHelper will return byte[] here. result = ImageHelper.getRawBytes(imageID); jObject = new JSONObject().put("RAWBYTES", result); return jObject; } But in JS, I am getting "RAWBYTES" value as [B@1ba4059f. I would like to get this as ArrayBuffer in JS.  Thanks In Advance.

Vote up!
0 votes
Vote down!

Hi Ganesh,

You cannot pass rawbytes as input to a service (as defined in Kony Middleware Server). You should convert the bytes to base64 string and send it as string input to the service.

Open Media Callback on android provides rawbytes which is the uri of the image when you print it it gives you the path. Convert that uri to actual file path of the image and resize,compress it and return the required base64 data back to JS layer.

Please find the sample app that we made where the pdf is converted to byte array and is converted to Object and the same we can get in kony through FFI callback. The datatype which we get from FFI is an Javascript Object type.

Thank You

Replied by: Apr 06, 2017 13:52 EDT