Re: Sending a File Over HTTP
- Posted by jimcbrown (admin) Aug 07, 2013
- 1983 views
euphoric said...
How do you send a large file over the Internet via HTTP with a Euphoria program?
I can program both the client and server (and both are programmed in Euphoria), I just need to know the best way. Is it necessary to use multi-part from the Euphoria program to push a file to a server?
Thanks!
Using multi-part appears to be supported.
Here's an example from the http test: http://scm.openeuphoria.org/hg/euphoria/file/01eab55e774d/tests/t_net_http.e
-- multipart form data sequence file_content = "Hello, World. This is an icon. I hope that this really works. I am not really sure but we will see" object data = { { "size", sprintf("%d", length(file_content)) }, { "file", file_content, "example.txt", "text/plain", ENCODE_BASE64 } } -- 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://test.openeuphoria.org/post_file.cgi", { MULTIPART_FORM_DATA, data }) if atom(content) or length(content) < 2 then test_fail("multipart form file upload") else test_equal("multipart form file upload", data[1][2] & "\n" & file_content, content[2]) end if