You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Nicolas Toper <nt...@jouve.fr> on 2004/01/22 15:04:08 UTC

File upload/Multipart form

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


Re: File upload/Multipart form

Posted by Jorg Heymans <jh...@domek.be>.
it does.

look for fileupload in the wiki/mailinglist

Nicolas Toper 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


Re: File upload/Multipart form

Posted by Lionel Crine <cr...@4dconcept.fr>.
No problem it's working.

I have just mention that using .get() instead of getAttribute() is OK.
getAttribute() method returns null but not get() method.




At 12:38 23/01/2004 -0500, you wrote:
>Lionel Crine wrote:
>>The code is complicated because, at some moment we have to check which 
>>content-type was coming and what to do.
>>I don't know if it was a good choice but it worked.
>>now, it's useless.
>>So I did what you said and here is a new example :
>>try {
>>Object oXml = this.request.get("moduleXml");
>>Part pod = (Part) oXml;
>>InputStream is = pod.getInputStream();
>>] catch ..........
>>
>>The getAttribute method returns null.
>
>Are you saying your new code above works now or doesn't?  The getAttribute 
>must have been a typo - that would never work.  The code above should be 
>all you need.  If not, write back with more info on what is wrong.
>
>Geoff
>
>
>>Lionel
>>At 07:51 23/01/2004 +0100, you wrote:
>>
>>>Lionel Crine wrote:
>>>
>>>>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();
>>>
>>>Hello Lionel,
>>>
>>>sorry, but I don't know why you use this complicated code to realize 
>>>uploads in cocoon. There is a solution which is very very easier!
>>>
>>>1.) Set enable-uploads to true in web.xml.
>>>2.) Get the uploaded file with request.getAttribute("filename_on_the_form");
>>>3.) After that you will receive an object of type PartOnDisk for 
>>>example. Use getFile() to receive the uploaded file.
>>>
>>>Thats it. Isn't it easy?
>>>
>>>More informations: 
>>>http://wiki.cocoondev.org/Wiki.jsp?page=FileUploadsWithCocoon2.1
>
>
>
>---------------------------------------------------------------------
>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


SaxExeption when migrating from 2.1.2 to 2.1.3

Posted by Nicolas Toper <nt...@jouve.fr>.
Hi,

When I try to migrate my webapp from 2.1.2 to 2.1.3 I got an "Internal cocoon 
problem" SaxException: try to output an integral value of 233 ...

Do you know what this is?

It comes from only a few files...

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


Re: File upload/Multipart form

Posted by Geoff Howard <co...@leverageweb.com>.
Lionel Crine wrote:
> The code is complicated because, at some moment we have to check which 
> content-type was coming and what to do.
> I don't know if it was a good choice but it worked.
> 
> now, it's useless.
> 
> So I did what you said and here is a new example :
> 
> try {
> 
> Object oXml = this.request.get("moduleXml");
> Part pod = (Part) oXml;
> InputStream is = pod.getInputStream();
> 
> ] catch ..........
> 
> 
> The getAttribute method returns null.

Are you saying your new code above works now or doesn't?  The 
getAttribute must have been a typo - that would never work.  The code 
above should be all you need.  If not, write back with more info on what 
is wrong.

Geoff


> Lionel
> 
> At 07:51 23/01/2004 +0100, you wrote:
> 
>> Lionel Crine wrote:
>>
>>> 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();
>>
>> Hello Lionel,
>>
>> sorry, but I don't know why you use this complicated code to realize 
>> uploads in cocoon. There is a solution which is very very easier!
>>
>> 1.) Set enable-uploads to true in web.xml.
>> 2.) Get the uploaded file with 
>> request.getAttribute("filename_on_the_form");
>> 3.) After that you will receive an object of type PartOnDisk for 
>> example. Use getFile() to receive the uploaded file.
>>
>> Thats it. Isn't it easy?
>>
>> More informations: 
>> http://wiki.cocoondev.org/Wiki.jsp?page=FileUploadsWithCocoon2.1



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


Re: File upload/Multipart form

Posted by Stephan Coboos <cr...@gmx.net>.
Stephan Coboos wrote:

> Lionel Crine wrote:
>
>> The code is complicated because, at some moment we have to check 
>> which content-type was coming and what to do.
>> I don't know if it was a good choice but it worked.
>>
>> now, it's useless.
>>
>> So I did what you said and here is a new example :
>>
>> try {
>>
>> Object oXml = this.request.get("moduleXml");
>> Part pod = (Part) oXml;
>> InputStream is = pod.getInputStream();
>>
>> ] catch ..........
>>
>>
>> The getAttribute method returns null.
>>
> Hello Lionel,
>
> two questions:
>
> 1.) Did you set the param "enable-uploads" to "true" in 
> $COCOON_HOME/WEB-INF/web.xml?
> 2.) Did you send your form with "enctype="multipart/form-data" and 
> "method='POST'"?
>
> ... then getAttribute() should not return null. If so, please give us 
> some code, so I will see to help you.
>
Hello Lionel,

I'am sorry. You're right it must be get() and not getAttribute().

Regards
Stephan



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


Re: File upload/Multipart form

Posted by Stephan Coboos <cr...@gmx.net>.
Lionel Crine wrote:

> The code is complicated because, at some moment we have to check which 
> content-type was coming and what to do.
> I don't know if it was a good choice but it worked.
>
> now, it's useless.
>
> So I did what you said and here is a new example :
>
> try {
>
> Object oXml = this.request.get("moduleXml");
> Part pod = (Part) oXml;
> InputStream is = pod.getInputStream();
>
> ] catch ..........
>
>
> The getAttribute method returns null.
>
Hello Lionel,

two questions:

1.) Did you set the param "enable-uploads" to "true" in 
$COCOON_HOME/WEB-INF/web.xml?
2.) Did you send your form with "enctype="multipart/form-data" and 
"method='POST'"?

... then getAttribute() should not return null. If so, please give us 
some code, so I will see to help you.

Regards
Stephan


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


Re: File upload/Multipart form

Posted by Lionel Crine <cr...@4dconcept.fr>.
The code is complicated because, at some moment we have to check which 
content-type was coming and what to do.
I don't know if it was a good choice but it worked.

now, it's useless.

So I did what you said and here is a new example :

try {

Object oXml = this.request.get("moduleXml");
Part pod = (Part) oXml;
InputStream is = pod.getInputStream();

] catch ..........


The getAttribute method returns null.


Lionel

At 07:51 23/01/2004 +0100, you wrote:
>Lionel Crine wrote:
>
>>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();
>
>
>Hello Lionel,
>
>sorry, but I don't know why you use this complicated code to realize 
>uploads in cocoon. There is a solution which is very very easier!
>
>1.) Set enable-uploads to true in web.xml.
>2.) Get the uploaded file with request.getAttribute("filename_on_the_form");
>3.) After that you will receive an object of type PartOnDisk for example. 
>Use getFile() to receive the uploaded file.
>
>Thats it. Isn't it easy?
>
>More informations: 
>http://wiki.cocoondev.org/Wiki.jsp?page=FileUploadsWithCocoon2.1
>
>Regards
>Stephan
>
>
>---------------------------------------------------------------------
>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


Re: File upload/Multipart form

Posted by Lincoln <li...@linc.net.au>.
I am trying to use the put method in an xform to put a file on the server.
As I am a newbie to forms and cocoon, should I be using your approach to get
a file on the server?

Linc

Lincoln Mitchell
hm: 618 9250 6772
mb: 0414 286 433
email: lincoln@linc.net.au
web: www.linc.net.au
----- Original Message -----
From: "Stephan Coboos" <cr...@gmx.net>
To: <us...@cocoon.apache.org>
Sent: Friday, January 23, 2004 2:51 PM
Subject: Re: File upload/Multipart form


> Lionel Crine wrote:
>
> > 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();
>
>
> Hello Lionel,
>
> sorry, but I don't know why you use this complicated code to realize
> uploads in cocoon. There is a solution which is very very easier!
>
> 1.) Set enable-uploads to true in web.xml.
> 2.) Get the uploaded file with
request.getAttribute("filename_on_the_form");
> 3.) After that you will receive an object of type PartOnDisk for
> example. Use getFile() to receive the uploaded file.
>
> Thats it. Isn't it easy?
>
> More informations:
> http://wiki.cocoondev.org/Wiki.jsp?page=FileUploadsWithCocoon2.1
>
> Regards
> Stephan
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org



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


Re: File upload/Multipart form

Posted by Stephan Coboos <cr...@gmx.net>.
Lionel Crine wrote:

> 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();


Hello Lionel,

sorry, but I don't know why you use this complicated code to realize 
uploads in cocoon. There is a solution which is very very easier!

1.) Set enable-uploads to true in web.xml.
2.) Get the uploaded file with request.getAttribute("filename_on_the_form");
3.) After that you will receive an object of type PartOnDisk for 
example. Use getFile() to receive the uploaded file.

Thats it. Isn't it easy?

More informations: 
http://wiki.cocoondev.org/Wiki.jsp?page=FileUploadsWithCocoon2.1

Regards
Stephan


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


Re: File upload/Multipart form

Posted by Lionel Crine <cr...@4dconcept.fr>.
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


Looking for function 2.1.4-dev with woody

Posted by Scott Simpson <ss...@watsys.com>.
Hi,

I've tried the latest nightly snapshots of 2.1.4-dev and woody seems to be broken.  Something seems to be wrong in the pipeline and
none of the samples work.  I also read a thread that a problem was introduced early January.  Does anyone know where to find the
latest working woody version?  (Maybe late December?)

Thanks


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