How to send photos from mobile app back to Progress database

Posted by mainroad1 on 06-Mar-2014 16:55

Hello:

Can anyone offer advice on how a mobile app could send photos back to a Progress database?

My development environment is OpenEdge Mobile App Builder 11.3.

Cheers,
gord.

All Replies

Posted by Jean Richert on 07-Mar-2014 07:26

Anyone following this forum could give nainroad1 some suggestions?

Posted by Anil Kumar on 07-Mar-2014 07:50

Hi Gord,

Currently we don't have support for CLOB and BLOB datatype support for REST and Mobile of OpenEdge.

Thanks and Regards,

Anil Kumar.

Posted by Shelley Chase on 07-Mar-2014 08:24

I have not done this but I am pretty sure you can serialize the image to a base64 string and pass it as a long character to OE. A google search shows some possible solutions like stackoverflow.com/.../how-to-get-image-bytes-string-base64-in-html5-jquery-javascript

-Shelley

Posted by gvtsstaggs on 07-Mar-2014 10:40

Our app saves pictures as schase has suggested. We currently use SOAP services, as opposed to REST services, to achieve this. I believe that the camera service allows you to state what format you want the image data to be in. We use Appery.io directly, instead of going through OE Mobile, so I'm not sure where the differences begin and end.

Good luck,

Solomon

Posted by mainroad1 on 07-Mar-2014 12:33

Thanks Shelley for the stackoverflow link.  I was wondering if anyone had done something like that and you've now pointed me to an example to use as a starting point.

It would be great if Progress added some blob/clob support to the REST service, but I fear that won't come very soon.

Even if Solomon is using Appery.io rather than OE Mobile it sounds like the serialization is working for him.  It's nice to learn that at least one person has made a success of this.

Cheers,

gord.

Posted by Ricardo Perdigao on 07-Mar-2014 12:48

Solomon,

That piece (Camera Service) is the same on OE Mobile and Appery.  

MainRoad1,

I have not done what you are asking :(

The challenge here is that the information would need to fit inside a CHAR field (to be sent by REST to the backend).

If I had time to play, I would try something like this:

- Map the ImageDataBase64 directly to a LocalStorageVariable and find how big it is.

- Write a JavaScript script to break that LocalStorageVariable into multiple smaller strings LocalStorageVariables  (not sure how many would you need in order to transfer a full resolution image in Base64). 

- I would map those multiple smaller string LocalStorageVariables  to CHAR fields on a REST Service and invoke the service to send the data

- On the backend, when I receive the char fields/strings, I would re-join them into a single base64 clob.

- Lastly, I would write ABL code to convert that base64 clob string back into a Jpeg.

I agree with you, it would be 1000x easier If we could just pass the whole base64 string as a single clob field.

Warm Regards,

Ricardo Perdigao

Posted by mainroad1 on 07-Mar-2014 13:52

Cheers Ricardo.  I appreciate the advice.

gord.

Posted by Robin Brown on 07-Mar-2014 15:35

As a general rule, we do not support CLOB and BLOB parameters in OpenEdge .  We do, however, support LONGCHAR and MEMPTR parameters and BLOB and CLOB temp-table fields in temp-table/dataset parameters..

Posted by Phillip Molly Malone on 10-Mar-2014 22:35

Have tested this out. Was able to send the output of the Camera service back to the AppServer (didn't save it into the database but stripped the first 24 chars (which note that its data, a JPG and in base64), decoded it with the base64-decode and then used copy-log to copy the resulting Memptr to an image file and it works). I used a CLOB field in a temp--table for the data. I first tried blob but it failed plus the output of the Camera control was string.

You would have to decide if to store in your database the encoded or decoded and if to strip the leading character when storing it in the database or when writing it to windows file (as the web can show it with those chars).

Not sure if this helps.

Posted by jackiep on 11-Mar-2014 11:24

The LONGCHAR sent from the app is BASE64 except for the start of the string which seems to be used by HTML browsers to tell them that it's a base64 encloded image.  Output the LONGCHAR to a text file using COPY-LOB, COPY-LOB it back into a LONGCHAR, stripping out the initial junk then BASE64-DECODE it into a memptr.  This can either then be displayed in a program or COPY-LOB into the database to store as a blob.

Posted by mainroad1 on 11-Mar-2014 14:24

Yes Phillip and Jackie that does help.  I'm almost ready to start working on the photo aspect of my app and every bit of advice gives me a better idea of how to approach the task.  Just hearing people say 'they've done it' (and some details) makes me a lot more optimistic that I'm heading down the right path.

Thanks,

gord.

Posted by John Goodland on 12-Mar-2014 04:05

Sorry mainroad1 I've been very busy recently (stuck in rooms with no windows). I have this working in my expenses app and I'm willing to share code. I will try to get something to Jean to create a KB entry as I suspect others will want this functionality.

In the meantime please feel free to drop me any questions.

Posted by mainroad1 on 12-Mar-2014 14:49

Thanks John.  Code examples that shorten my development time are always very welcome!

Cheers,

gord.

Posted by Jean Richert on 12-Mar-2014 15:44

[mention:752d73af517b4879a49438d4ddf72e89:e9ed411860ed4f2ba0265705b8793d05] you said: "It would be great if Progress added some blob/clob support to the REST service, but I fear that won't come very soon."...

Please feel free to report your suggestion in our Community Ideas.

Pick the product ad then you can enter your idea.

Others can then contribute, comment, promote/demote and collaborate.

https://community.progress.com/community_groups/products_enhancements/ 

Posted by Phillip Molly Malone on 12-Mar-2014 17:48

While I'm sure that we would be happy to get any ideas/code/how to procedures to add to the KB, perhaps creating a forum post/wiki entry or document for it on the Community would be a better option for sharing it. If the question is asked via a call and a knowledge entry is needed, we could always point to the community page with the points. I personally (insert disclaimer about my own views not employers view here) would love to see a lot of these "how to" in lots of areas but especially around mobile turn up on the Community. I think it will be a great way to encourage people that work out these technical issues to share their findings as they figure if they do it, then maybe they will save time later on when someone shares the code that they didn't have to work out themselves.

JMTC

PS. Hope this makes sense.

Posted by mainroad1 on 12-Mar-2014 19:01

Suggestion posted!

gord.

This thread is closed