Upload File HTTP Post Request

Discussion forum about all things Team Developer 7.x
andreadpt92
Italy
Posts: 10
Joined: 14 Oct 2018, 13:26
Location: Italy

Upload File HTTP Post Request

Post by andreadpt92 » 14 Oct 2018, 13:30

Hello Team,

I have to develop a no net application that uploads a file via a post HTTP request.

I'm asked to simulate the action of a form-date using a file field.

API used uses iFormFile for asp.net.


Does anyone have any ideas?

Thanks

Igor Ivanovic
Site Admin
Site Admin
Croatia
Posts: 1203
Joined: 05 Mar 2017, 12:37
Location: Zagreb, Croatia

Re: Upload File HTTP Post Request

Post by Igor Ivanovic » 15 Oct 2018, 06:42

Hi,

Long time ago we created a general window class for such things using wsock32.dll (you can find the definition of functions here: https://wiki.tdcommunity.net/index.php/WinAPI32.
You can also find some examples on how to use it in the wiki samples section: https://samples.tdcommunity.net/, just search for winsock.
It is a rather low level approach, but we are using it for a number of things for over 15 years.
The only change was when we switched to unicode versions of TD.
Igor Ivanovic
Image

andreadpt92
Italy
Posts: 10
Joined: 14 Oct 2018, 13:26
Location: Italy

Re: Upload File HTTP Post Request

Post by andreadpt92 » 15 Oct 2018, 13:34

Thanks for the reply.

However, I can not find the correct information.

Through MSXML6.0 I can open the HTTP connection and pass all the parameters in post mode except the file to be uploaded.

I tried to create a doc object and pass it as an attachment but it is not recognized, how could I simulate the file object of an html form ?.

thanks a lot

Andrea

andreadpt92
Italy
Posts: 10
Joined: 14 Oct 2018, 13:26
Location: Italy

Re: Upload File HTTP Post Request

Post by andreadpt92 » 19 Oct 2018, 12:52

Does anyone have any ideas?

thomas.uttendorfer
Site Admin
Site Admin
Germany
Posts: 187
Joined: 05 Mar 2017, 17:19
Location: Munich Germany

Re: Upload File HTTP Post Request

Post by thomas.uttendorfer » 19 Oct 2018, 13:26

Hi Andrea,
I did that with wrapping http-functions wininet32.dll from Windows.
Maybe that helps you - look at internal function Main() for usage.
wininet_sample.zip
Regards Thomas
You do not have the required permissions to view the files attached to this post.
Thomas Uttendorfer
[ frevel & fey ] Software-System GmbH
https://thomasuttendorfer.wordpress.com/

andreadpt92
Italy
Posts: 10
Joined: 14 Oct 2018, 13:26
Location: Italy

Re: Upload File HTTP Post Request

Post by andreadpt92 » 19 Oct 2018, 13:49

Thank you,

the call I could do it, the real problem is to simulate the HTML object <INPUT FILE = ....

I can not pass it in any way, do you have any examples to leave me?

thomas.uttendorfer
Site Admin
Site Admin
Germany
Posts: 187
Joined: 05 Mar 2017, 17:19
Location: Munich Germany

Re: Upload File HTTP Post Request

Post by thomas.uttendorfer » 19 Oct 2018, 14:11

Hi Andrea,
not sure what the problem is:
You have to create the body of the http-request?
Maybe you can do that in a browser and use fiddler to catch the http-traffic.
Then you see how the data should look like and do the same in Gupta.
Regards Thomas
Thomas Uttendorfer
[ frevel & fey ] Software-System GmbH
https://thomasuttendorfer.wordpress.com/

andreadpt92
Italy
Posts: 10
Joined: 14 Oct 2018, 13:26
Location: Italy

Re: Upload File HTTP Post Request

Post by andreadpt92 » 19 Oct 2018, 14:19

unfortunately the browser does not use the files as simple parameters but transforms them into blobs and is not inserted in the body of the request.
I tried to transform the file into blobs and insert it both in the header and in the body but without success.

I saw that in C # they use strams to solve a problem.

thomas.uttendorfer
Site Admin
Site Admin
Germany
Posts: 187
Joined: 05 Mar 2017, 17:19
Location: Munich Germany

Re: Upload File HTTP Post Request

Post by thomas.uttendorfer » 19 Oct 2018, 14:33

Hi Andrea,

I'm a bit confused since the topic is called "Upload File HTTP Post Request".
So the file is uploaded using a different protocol?

Regards Thomas
Thomas Uttendorfer
[ frevel & fey ] Software-System GmbH
https://thomasuttendorfer.wordpress.com/

andreadpt92
Italy
Posts: 10
Joined: 14 Oct 2018, 13:26
Location: Italy

Re: Upload File HTTP Post Request

Post by andreadpt92 » 19 Oct 2018, 15:34

Hello,

the protocol is HTTP POST.

I have to simulate the action of:
<html>
<form name ='test' action = '. /upload.php' method = 'POST'>
<input type = file name = file_upload>
</form>
</html>

thomas.uttendorfer
Site Admin
Site Admin
Germany
Posts: 187
Joined: 05 Mar 2017, 17:19
Location: Munich Germany

Re: Upload File HTTP Post Request

Post by thomas.uttendorfer » 22 Oct 2018, 13:20

Hi Andrea,
the intereting thing is: what does update.php do?
Have you tried to look at this with fiddler (from Telerik)?

Regards Thomas
Thomas Uttendorfer
[ frevel & fey ] Software-System GmbH
https://thomasuttendorfer.wordpress.com/

Return to “General Discussion”

Who is online

Users browsing this forum: [Ccbot] and 0 guests