Re: Sending a File Over HTTP
- Posted by jimcbrown (admin) Aug 07, 2013
- 1964 views
Hi
Coincidental, this topic has just become live for me again, I've just received a test account, the login details, and the specs from my supplier. I have a suspicion that euphoria can't as yest post a text file (I could be wrong), but am about to start writing test programs)
http://openeuphoria.org/forum/120643.wc#120643
Chris
Aren't you using curl or libcurl for that? Posting a text file the standard way should work just fine with the stdlib, but your case is not standard.
Untested, but I just mocked up a version of http.e that should do what you need. See http://openeuphoria.org/pastey/229.wc
Here's how you'd call it (assuming that it works):
-- custom data sequence file_content = "COMMAND\tORDER\r\nAUTH\t\YES\r\n..." -- if you have a text file in the right format with the right data, -- you should be able to just read its contents into file_content as -- a flat sequence -- post file script gets size and file parameters, calls decode_base64, and sends -- back SIZE\nDECODED_FILE_CONTENTS. The test script is written in Perl to test against -- modules we did not code, i.e. CGI and Base64 in this case. object content = http_post("http://confidential/program.cgi", { RAW_POST_DATA, "application/x-what-goes-here", file_content })
Your posts didn't specify if a particular content-type was required, and if so what that should be (e.g application/x-what-goes-here). Your data interface specs should have this information.