Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 7 of 7 total
Thread Sending a file from the client
Mon, Oct 19 2020 9:50 PMPermanent Link

Paul Coshott

Avatar

Hi All,

I need to send a csv file to the server. I am using TMS's XData to build my rest server and it expects to receive a TStream.

What do I need to do to send the csv file over using a TServerRequest component?

Thanks,
Paul
Tue, Oct 20 2020 4:00 AMPermanent Link

Walter Matte

Tactical Business Corporation

Paul

It may land in the XData server as a TStream - but it is probably transfered as encoded binary or byte array and isn't XData all JSON?? I don;t know have not used.  But if it is you should be able to see the JSON package via Fiddler.

You need to to a test and use Fiddler and capture a small transaction that you want to reproduce from an EWB web app.

In Fiddler you should see all the header and data (json) being sent to XData - then you can see if / how to do that with EWB.

Walter
Tue, Oct 20 2020 9:53 AMPermanent Link

Paul Coshott

Avatar

Hi Walter,

Thanks for answering. In XData I can do the following:

procedure TMyService.ReceiveFile(Content: TStream);

and then save the TStream to a file.

I'm just not sure how to send the file from EWB using a TServerRequest. So how would I transfer as encoded binary or byte array?

Thanks,
Paul
Wed, Oct 21 2020 6:46 AMPermanent Link

Walter Matte

Tactical Business Corporation

Paul:

Do you want the client to upload a file?

There is a demo on uploading a file.

I put a TFileComboBox on a THTMLForm - Method - fmPost.  

They select the file via TFileComboBox.

Another button is clicked that HTMLForm.Submit.   This start the file upload.

You can put other controls - edit boxes on the THTMLForm and they are uploaded to.  So Editboxes that are Visible = Flase - can contain other information that gets Posted (sent) to the Server.

I don't know if this helps for th especifics of XData.

Walter
Wed, Oct 21 2020 6:46 AMPermanent Link

Walter Matte

Tactical Business Corporation

Paul:

Do you want the client to upload a file?

There is a demo on uploading a file.

I put a TFileComboBox on a THTMLForm - Method - fmPost.  

They select the file via TFileComboBox.

Another button is clicked that HTMLForm.Submit.   This start the file upload.

You can put other controls - edit boxes on the THTMLForm and they are uploaded to.  So Editboxes that are Visible = Flase - can contain other information that gets Posted (sent) to the Server.

I don't know if this helps for th especifics of XData.

Walter
Wed, Oct 21 2020 9:52 AMPermanent Link

Paul Coshott

Avatar

Walter Matte wrote:

>> I put a TFileComboBox on a THTMLForm - Method - fmPost.  

Hi Walter,

I'm not sure, but maybe this could work. I was hoping I could do it with a TServerRequest, in the same way I have sent other data to the server.

Cheers,
Paul
Wed, Oct 21 2020 11:47 AMPermanent Link

Raul

Globestar Systems

Team Elevate Team Elevate

On 10/21/2020 9:52 AM, Paul Coshott wrote:
> I'm not sure, but maybe this could work. I was hoping I could do it with a TServerRequest, in the same way I have sent other data to the server.
>

As mentioned before form submit option will work.

Otherwise see for example this thread for solution that would allow one
to drag and drop file and then you get it as base64 and use TServerRequest

https://www.elevatesoft.com/forums?action=view&category=ewb&id=ewb_demos&page=1&msg=210#210


More is coming in EWB3 (FileAPI support) but that is all that's possible
today in EWB2 AFAIK (unless you craft some even custom json yourself )

Raul
Image