Re: Post multipart (Uploading file) with ocamlnet
Gerd Stolpmann <[email protected]> Wed, 14 Dec 2011 14:04:34 +0100
| Newsgroups | gmane.comp.lang.ocaml.lib.net.devel |
|---|---|
| Message-ID | <1323867874.7750.33.camel@samsung> |
Hello Pierre-Alexandre, netcgi parses POSTed arguments already for you. You can simply access them with the normal cgi#argument mechanism. E.g. to get the result of a file upload named "upload": let arg = cgi#argument "upload" To read the uploaded data into a string: let data = arg#value To get the (server) filename where the uploaded data is temporarily stored: let server_file = match arg#store with | `File fn -> fn | `Memory -> failwith "Not stored in a file" There are a few more methods for arguments, see the docs. Don't forget to finally delete the temporary files where the uploads are stored. This can easily be done with cgi#finalize() Hope this helps, Gerd Am Montag, den 12.12.2011, 18:53 +0100 schrieb Pierre-Alexandre Voye: > Hello, > > I'm trying to finding my path to uploading a file via HTTP/POST, by > parsing a multipart form data, and i have to admit i'm lost. > > I start from a netcgi, which with i can handle argument > let process (cgi : Netcgi.cgi_activation) = > try > let out = cgi # output # output_string in > match cgi#request_method with > | `POST -> let t = > cgi#environment#input_header() in out "rrrhh" > cgi # output # commit_work(); > with > error -> print_endline "toto" > ;; > > As far as i understand, i have to get the raw data, and to parse it > with Netmime module, > so my value "t" which contains cgi#environment#input_header() would > contains interesting data, but the type Netmime.mime_header only > provide methods to modify data.. > > Does anyone could give a hook to find a path ? > > Thank you very much, > > Regards, > > P-A > > > > -- > --------------------- > https://twitter.com/#!/ontologiae/ > http://linuxfr.org/users/montaigne > > ------------------------------------------------------------------------------ > Learn Windows Azure Live! Tuesday, Dec 13, 2011 > Microsoft is holding a special Learn Windows Azure training event for > developers. It will provide a great way to learn Windows Azure and what it > provides. You can attend the event by watching it streamed LIVE online. > Learn more at http://p.sf.net/sfu/ms-windowsazure > _______________________________________________ Ocamlnet-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/ocamlnet-devel ------------------------------------------------------------------------------ Cloud Computing - Latest Buzzword or a Glimpse of the Future? This paper surveys cloud computing today: What are the benefits? Why are businesses embracing it? What are its payoffs and pitfalls? http://www.accelacomm.com/jaw/sdnl/114/51425149/