1. Sivaprakash BKR
  2. PowerBuilder
  3. Tuesday, 23 November 2021 07:46 AM UTC

Hello,

PB 2019 R3, Postgresql 11

I could store and retrieve image files that's stored from the Powerbuilder application.   Now through a mobile application, they store images in the same database that PB applications need to retrieve and update.   Simply images stored from one (PB/mobile) application should be modifiable from other (mobile/PB) application(s).

We store data from PB application using UPDATEBLOB command.

We store data from Mobile application using
// convert image to byte
ls_byte = ImageToBytes(ib_bitmap)

// convert byte to EncodeBase64
ls_base64string = ls_stringutils.EncodeBase64(ls_byte)

// Pass this base64 string to Web API and storing that in the database.

Is this process correct?   Reverting the same process we could view the image in the mobile application.

But not in the PB application.  Any idea how to store images from a mobile application so that we can view the same from the PB application and vice versa?

Happiness Always
BKR Sivaprakash

 

Accepted Answer
Sivaprakash BKR Accepted Answer Pending Moderation
  1. Tuesday, 30 November 2021 07:02 AM UTC
  2. PowerBuilder
  3. # Permalink

Hello,

Found the issue in our test application.  It's was in the PHP's insert statement.  Instead of issuing a direct Insert statement in PHP, we changed it into a prepared statement, the issue got solved.    Now we could save images in PB, view them in Mobile applications, and vice-versa.   Need to implement and test it in real applications.  Will do it soon.

For those who are interested,

IN PowerBuilder
1.  We used the regular SelectBlob and UpdateBlob commands to retrieve and save images in bytea field

IN Mobile Application (B4A and PHP)
B4A
1.  Convert image to a byte array using ImageToBytes  [ Wrote a customer function ]
2.  Encode the resultant byte array using Base64
3.  Send the result to WebAPI through JSON

PHP
1.  Decode the received, encoded value
2.  Insert the returned data using the prepared statement.

HTH

Happiness Always
BKR Sivaprakash

 

Comment
  1. Miguel Leeuwe
  2. Tuesday, 30 November 2021 09:04 AM UTC
Thanks for sharing! (Love B4A by the way).
  1. Helpful
There are no comments made yet.
mike S Accepted Answer Pending Moderation
  1. Wednesday, 24 November 2021 14:45 PM UTC
  2. PowerBuilder
  3. # 1

-->// Pass this base64 string to Web API and storing that in the database.

the mobile application doesn't do anything with storing the image, the web api does.  what does the web api do?

if it just stores the text (you converted the blob to text via the base64 call) , then you need to convert it from text back to a blob in PB, store that to a file then start up a viewer to see it.  and have your PB application store blobs as base64 text as well.

 

Comment
  1. Krithika BS
  2. Thursday, 25 November 2021 08:38 AM UTC
Thanks mike S

Mobile application, calls API written in PHP, sends base64encoded data. PHP function should convert the encoded data back to blob and save it. We are trying to find out what that PHP function does (we don't have access to that PHP code). We were told that it does, as they could view the same image from the mobile application.

Now as we slowly integrating that mobile application with PB application, we started finding issue, in displaying the image captured / stored from mobile application, in a PB application.

The other way is working. ie. we captured an image in PB application, asked the mobile developer to display the same in the mobile. It's working.

May be a small issue somewhere....

  1. Helpful
There are no comments made yet.
Miguel Leeuwe Accepted Answer Pending Moderation
  1. Wednesday, 24 November 2021 04:18 AM UTC
  2. PowerBuilder
  3. # 2

I think that Powerbuilder might need the "file headers" to be present in the blob, to properly show the image, unless you use an inkPicture, which has the LoadPicture() function or an InkPicture object in a datawindow (no experience with that last one though).

So I think that if you are using a normal picture control, you'd have to first write the blob to disk as an image file.

I'm just guessing here, it's for you to try it out.

regards.

Comment
There are no comments made yet.
  • Page :
  • 1


There are no replies made for this question yet.
However, you are not allowed to reply to this question.