Image Upload in SD App via REST

1

Genexus 15 build 107258 .NET

I have an offline application that I synchronize with the server manually. I have a Transaction with an attribute Image that corresponds to a photo that is taken on the device. That photo must be synchronized like the rest of the attributes of Transaction . I have already managed to synchronize all the attributes via REST minus the photo. I saw that there is a document in the wiki and I'm testing it with a Web Panel that takes the path of the file to upload from the client, or something like:

  

C: \ images \ image.jpg

and the server gives me the following error:

  

[HttpException]: A possible Request.Path value was detected   dangerous in the client (:). in   System.Web.HttpRequest.ValidateInputIfRequiredByConfig () in   System.Web.HttpApplication.PipelineStepManager.ValidateHelper (HttpContext   context)

How is the file passed to object HttpClient ? Then, when I go to do it in SD, do I have to have some additional consideration?

    
asked by bcamargo75 02.05.2017 в 15:07
source

1 answer

2

The automatic synchronization what it does is upload the files first (images, audio, video, etc.) and then when sending the data it sends identifiers instead of the binaries. Your solution "by hand" I suppose I should do something similar.

The easiest way to upload an image is by calling a Procedure , which receives the image by parameter:

parm(in:&someImage, out:&tempImageIdentifier);

The Procedure should return some type of identifier and then know what the image is.

Another option is to send everything in a SDT as a parameter of Procedure , in that case the upload of all the images will be done automatically, and they will be available as members of SDT in Procedure on the server.

For example:

&sdt = new()
&sdtItem = new()
&sdtItem.Id = &id
&sdtItem.Image = &image
&sdt.Items.add(&sdtItem)
...
SendData(&sdt)   // este es el procedure que se expone como REST, tiene que tener Connectivity Support = Online

See this document: Procedures as REST: Using SDT as input to the procedure

    
answered by 03.05.2017 в 14:06