Hi,
It seems in servlets, the request parameter handling is not consistent
across all request content types. i.e. When the content type is
multipart/form-data, we can't access parameters just using
request.getParameter("foo"). In order to handle multipart/form-data, best
practice would be to use commons-fileupload.
So, it would be better if we can give an easier API to handle
multipart/form-data in Jaggery. In Jaggery, we also have
request.getParameter("foo") method to get string params sent with
application/x-www-form-urlencoded request. But it fails at the moment with
multiparts, but can be handled it properly using commons-fileupload.
In Jaggery API level, we can have the following. Please reply with your
suggessions.
request.getParameter("foo"); //return either string or File object
depending on the content type/field type
or
request.getFile("foo"); //instead of using getParameter() method, we can
have this method to get file uploads
Further, following methods too would be useful.
request.getFileMap(); // which will return list of file fields
request.getParameterMap();//list of all parameters in the request
request.isMultipart();
As we now have a Stream Hostobject to effiently deal with stream contents,
we can make the returned File object to directly deal with the uploaded
stream. So, we can just pass the uploaded file stream to any other HO which
deals with streams or save to the disk.
In order to save it, what would be the better method?
file.save("/foo.jpg"); or file.move("/foo.jpg");
Confusion between save() vs move() is due to the write() method we have in
File HO. i.e. If we opened a file with
var file = new File("myFile.tx");
then file.write(content); instantly save content to the file and
save()function won't needed in that case. But move() is valid always.
So, what
would be the more appropriate method?
The last question, in order to convert the content of a Stream object to a
string, what would be the better method name?
stream.serialize() or stream.toString()
--
Ruchira Wageesha
Software Engineer - WSO2 Inc. www.wso2.com
Email: [email protected] Blog: [email protected]
Mobile: +94775493444
Lean . Enterprise . Middleware
_______________________________________________
Dev mailing list
[email protected]
http://wso2.org/cgi-bin/mailman/listinfo/dev