cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Tobias Rübner <artf...@web.de>
Subject Re: [Cocoon 2.2] upload binary files
Date Sat, 08 Mar 2008 18:14:38 GMT
Thanks for the suggestions.

 >> You must save them yourself during the request processing.

Here is a snippet of my servlet:

public void doPost(HttpServletRequest request, HttpServletResponse  
response)
   throws ServletException, IOException {
     String path = request.getParameter("file");
// prints the correct filepath defined by the cocoon param + the  
filename
     logger.info(path);
     File file = new File(path);
// says false
     logger.info(file.exists());

// here my bean definition
   <bean id="com.mydomain.myapp.upload-servlet"  
class="com.mydomain.myapp.UploadServlet">
     <servlet:context mount-path="/upload" />
   </bean>

So, during the request, how can I save the file permamently to disc?

 >>I would not try to disable multipart filter. But if you can tell us  
what you actually want to do with the file it is easier for us to give  
suggestions how to set it up.

I have 2 concerns.
First, I want to save the file permamently to disc.
My second concern is to save this file to a remote application with a  
propriatary connection api.
I allready have classes that can handle the file, when it is on the  
disc.

Tobias



On Mar 8, 2008, at 10:01 AM, Joerg Heinicke wrote:

> I might be wrong, but my guess is you are falling into the trap that  
> uploaded files are deleted at the end of a request. You must save  
> them yourself during the request processing.
>
> I would not try to disable multipart filter. But if you can tell us  
> what you actually want to do with the file it is easier for us to  
> give suggestions how to set it up. You may also show us your current  
> set up so that we can tell you were it might go wrong.
>
> Joerg
>
> On 07.03.2008 12:32, Tobias Rübner wrote:
>
>> I am building a webapp with cocoon 2.2.
>> Currently I got stuck with the file upload.
>> First I tried to work with a HTTP Servlet and  
>> apache.commons.FileUpload.
>> But the MultipartHttpServletRequest changed the request and so  
>> there is no filedata to handle.
>> The parameter named like the file-input now contains the path to  
>> the upload directory, but in the file system no file exists.
>> Then I tried to use the tuturial provided at the cocoon wiki:
>> http://wiki.apache.org/cocoon/FileUploadsWithFlow
>> but I could not find any FileUploadManager in the current cocoon  
>> implementation.
>> So, can you tell me, how to access a uploaded binary file in a  
>> servlet?
>> What do I have to enter in the cocoon sitemap?
>> Maybe there is an other way to process the file with cocoon or
>> there is a way to disable the MultipartHttpServletRequest Filter?
>> Tobias
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org
>


Mime
View raw message