Welcome! Log In Create A New Profile

Advanced

HTTP post as a way to transfer files

Posted by Sead Grbesic 
HTTP post as a way to transfer files
August 04, 2023 03:52PM
Hello everyone,

I have two questions:
1. How do I send a file using HTTP post.
2. How to download files using an HTTP link to a specific folder on my own computer.
If anyone can help where I could find even the simplest examples for this.

Best regards
Argus
Re: HTTP post as a way to transfer files
August 12, 2023 01:32PM
in httppost, the content is sent in a buffer...
So on the server file, the answer to the httprequest is simply sending the file back
On the client side, you put the answer in a buffer and do a fsavebuffer where you want...

Now, often, you need to also send information (file name by example)...
In such a case, I start my buffer with an information string+CR and the file afterward, as on the client side, it's just a question of removing everything up to the CR

In case of problem, you can also encode the file buffer in BASE64 so that it is a string, and decode it on the browser side.
Re: HTTP post as a way to transfer files
August 18, 2023 04:07PM
Hi Argus,

I have created a procedure to send two csv files to an HTTP server and I get a response that the files have been sent. But those files do not physically appear on the server.
That code is:

Send_CSV(File1.csv, File2.csv)

PROCEDURE Send_CSV( sFileToSend1, sFileToSend2)

sHTTPLink is string
sHTTPLink = "[www.test.com];

HTTPCreateForm("FORM")
HTTPAddFile("FORM", "file1", sFileToSend1)
HTTPAddFile("FORM", "file2", sFileToSend2)

IF NOT HTTPSendForm("FORM", sHTTPLink,
httpPost,"","",typeMimeMultiPartForm,NoSpace(gsHTTP_Link_User),NoSpace(gsHTTP_Link_Password)) THEN
Error("Error sending files; ", ErrorInfo())
ELSE
InfoWithTimeout(500, "Successfully sending files!")
END


I would like to ask you, if I don't take a lot of your time, to show me an example of sending in the code.
1. files are example_file1.csv and example_file2.csv
2. The HTTP link is [test.com]
So, the files under serial number 1 should be sent to the link under serial number 2 and receive an answer that it has arrived at the destination or a report why it has not, if not.
I hope this is not a problem for you and I thank you in advance.
Best regards,
Sead



Edited 6 time(s). Last edit at 08/19/2023 07:39AM by Sead Grbesic.
Author:

Your Email:


Subject:


Spam prevention:
Please, enter the code that you see below in the input field. This is for blocking bots that try to post this form automatically. If the code is hard to read, then just try to guess it right. If you enter the wrong code, a new image is created and you get another chance to enter it right.
Message: