Nicola
Nicola

Reputation: 297

Send an image from smart device to the server in Genexus

I know there is already a similar question but the answers to that didn't work for me

I'm working with Genexus 16U11 and I have a panel with an image variable (called &sourceImage) with control type as "SD Image Annotation". I need to send this image to the server, in a specific folder. According the documentation if I call a procedure using the image as variable this should go on the server but it's not working. I can't find the image anywhere, I searched also in the PublicTempStorage directory, in the procedure is as the variable is empty.

I tried also to convert the image in base64 to send it as longvarchar to the procedure

&blob = &sourceImage.GetAnnotatedImage()
&longvarchar = ToBase64(&blob)

but in this way I can only get this string ZmlsZTovLy8vc3RvcmFnZS9lbXVsYXRlZC8wL0FuZHJvaWQvZGF0YS9jb20uYXJ0ZWNoLnJpY2hpZXN0YXBlcm1lc3NpMTZ1MTEuc2Zpcm1hL2ZpbGVzL3RyYW5zZm9ybWF0aW9ucy8yMDIyLTAzLTE4LS0xNC00My0yNi02MTQ2NDcyMTA5MjM5NDU3NzgzODAxLnBuZw==

that is the path of the file

file:////storage/emulated/0/Android/data/com.artech.richiestapermessi16u11.sfirma/files/transformations/2022-03-18--14-43-26-6146472109239457783801.png

I tried with file variable, blob, image, extra images, method fromUrl, nothing is working.

What am I doing wrong?

Upvotes: 1

Views: 462

Answers (1)

fpanizza
fpanizza

Reputation: 1589

To upload the image to the server you need to call the procedure in the server (Connectivity=Online). Then the image variable will be send to the server and you can save, copy, etc. there.

For example, save in a Transaction with a code like this:

Call in the panel:

  Composite
    &resultImage = &ImageA.GetAnnotatedImage()
    procSaveImage(&resultImage)
  EndComposite  

Procedure online:

&TrnData = new()
&TrnData.TrnDataImage = &parmImage
&TrnData.Insert()

if &TrnData.Success()
     commit 

Working in Genexus v17u8 .

Upvotes: 0

Related Questions