About Base64Convertor with TableViewer

Hi all,

My scenario is: I have a tableviewer that I use to populate a SQLite table and in each record has two images. So, I write the record this way:

And when I have to edit a record in tableviewer I do this:

And the result is none of images appear in edition. So, I was taking a look into this block:

And I am trying to understand if I have to put a completed filepath in the filePath or it could be with another way...

My goal is to insert images into a tableviewer, but instead of showing the filepath, I need to show image, but when I have to edit, I need to have its filepath in order to update with another picture and so on. After all of this, I send to a MySQL remote server (this step is ok already).

Just to be more clear: I am doing this, to indicate the path where images are stored:

And when I get images to insert into tableviewer, I do this:


approximately 2/3 of the way down the list blocks pallette.

You might have to read them.

The base64 extension accepts an absolute filepath, what this is will depend on where the image is that you want to convert, but for example if the image is in your Download folder, then the filepath would be:

/storage/emulated/0/Download/yourimage.png

You can use the file component to construct filepaths for the ASD or Assets, just remember to remove the file:// from the beginning of the path.

Some advice:

  • store your images as datauris, that is, add the data:image/png;base64, before the base64String. You can then easily view the image in a webviwer. You can always remove the datauri prefix if required.

  • do not try to view the base64 String in a textbox or label, this can fail and crash your app

Got it.

Whe you say this, means when I am editing image or seeing in tableviewer?

I misread your blocks:

image

but this will not display an image, correct, because you store that field as a base64String ?

Yes, that's right. Here is the point I don't know what to do to see the images... That's why I asked about this block:

As I said, create a datauri, then view the image in a webviewer instead of an image component, then you do not have to create a file.

1 Like

Ok, I will try it. Thanks again

datauri means? Can you explain with blocks?

If you don't mind can you share the blocks as well (or .aia file), So I also can learn it.

Have you lost the power of search ?

3 Likes

Hi @TIMAI2,

Sorry for post about this again. But I am trying to do this with webviewer and the result is not what I am expecting for.

I tried many times to do this, but when showing the image in webviewer is not good. I am doing this way to store the image in SQLite:

The webviewer is defined this way:

is there anything I am forgetting? Where am I doing wrong?

TIA,
Kleyber

Why would the Webviewer1.HomeUrl be used for generating a base64String of an image ? Do you not need to be providing the output of your field from sqlite record here, with no need to convert it to a file ?

You are missing a '> after your base64 string:

data: image/png;base64,<img src='[base64String of image]'>

Yes, sorry. The corrected image is:

See above re HomeUrl/CurrentUrl ...

Yeah, i confess I am a little bit lost with this...

Now I've found a way. It's running ok. What I was trying to do is instead of show the path in TableViewer, I was trying to show image, but I went to a wrong way. I came back, just change ImagePicker to AcrtivityStarter, showing the path (as it was before) and now everything is ok.
The image in TableViewer is another case.

Thank you, @TIMAI2 for all help.

2 Likes