cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Lionel Crine <cr...@4dconcept.fr>
Subject Re: File upload/Multipart form
Date Thu, 22 Jan 2004 18:36:32 GMT
Here is a sample code :

HttpServletRequest request = (HttpServletRequest) 
objectModel.get(HttpEnvironment.HTTP_REQUEST_OBJECT);
contentType = request.getContentType();
if (contentType == null) {
contentType = parameters.getParameter("defaultContentType", null);
}
if (contentType == null) {
throw new Exception("ERROR");
} else if (contentType.startsWith("application/x-www-form-urlencoded") || 
contentType.startsWith("multipart/form-data")) {
String parameter = parameters.getParameter(FORM_NAME, null);
if (parameter == null) {
throw new Exception("ERROR");
}
String sXml = request.getParameter(parameter);
inputSource = new InputSource(new FileInputStream(sXml));

} else if (contentType.startsWith("text/plain") || 
contentType.startsWith("text/xml") || 
contentType.startsWith("application/xml")) {

len = request.getContentLength();
if (len > 0) {
PostInputStream anStream = new PostInputStream(request.getInputStream(), len);
inputSource = new InputSource(anStream);
} else {
throw new SyspeoException("ERROR);
}
} else {
throw new SyspeoException("ERROR);
}

InputStream is = inputSource.getByteStream();



This code is adapted from StreamGenerator.
An action can do the same.

Lionel


At 15:04 22/01/2004 +0100, you wrote:
>Hello list ;=)
>Do you know if Cocoon handles multipart form like*
><form action="doaction">
>         <input type="file" />
>         <input type="text"/>
></form>
>
>I can't find the answer in the documentation.
>
>Thanks for your answer.
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
>For additional commands, e-mail: users-help@cocoon.apache.org

Lionel CRINE
Ingénieur Systèmes documentaires
Société : 4DConcept
22 rue Etienne de Jouy 78353 JOUY EN JOSAS
Tel : 01.34.58.70.70 Fax : 01.39.58.70.70


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Mime
View raw message