Anjib,

First of all, I replied to your query assuming that you are using Struts2. 
( This seems to be the most common confusion in this mailing list. I 
wonder why Struts2 does not have its own mailing list? The answers are 
always different!! )

Anyways, after looking at your code, I can still see that you are using 
commons-fileupload. So most of my comments still apply, except for the 
part where I wrote that the interceptor deletes the file. But if you take 
a look at the RequestProcessor, I think you might find similar code there 
too. 

- RM



From:
Anjib Mulepati <anji...@hotmail.com>
To:
Struts Users Mailing List <user@struts.apache.org>
Date:
14-10-2010 02:02
Subject:
Re: Store permanently file in temp directory



  Yes I am sure

I am working on front side only so I am sending stream to server using 
delegate provided by the server.

My code skeleton is as follow:

@Override
     protected ActionForward executeAction(ActionMapping mapping,
             ActionForm form, HttpServletRequest request,
             HttpServletResponse response) throws IOException, 
ServletException {

         UploadForm uploadForm = (UploadForm) form;
         DataHandler dataHandler = null;

         boolean isMultipart = 
ServletFileUpload.isMultipartContent(request);

         if (isMultipart) {
             //get filename and filecontent and create data handler
dataHandler = getDataHandler(fileName, fileContent);

             /* Create server delegate and pass dataHandler
                 Here file is written to my web server and then send to 
the database.
                 So I have to manually delete those file from filesystem 
after this statement */
             serverDelegate.addFile(fileName, fileSize, dataHandler);

             // Code to delete the file from the web server.
         }
     }

My artitecture is

              ---------------------------------------------   - 
-----------------------------
             | Browser <----->  Web Server <--- | ---> Server <-----> DB |
              --------------------------------------------- 
-------------------------------
                            client side

Anjib

On 10/13/2010 4:14 PM, Dave Newton wrote:
> You're not? You sure?
>
> 
http://www.mvnbrowser.com/artifact-details.html?groupId=struts&artifactId=struts&version=1.2.9&tab=DEPENDENCIES#tabs

>
> <
http://www.mvnbrowser.com/artifact-details.html?groupId=struts&artifactId=struts&version=1.2.9&tab=DEPENDENCIES#tabs
>
> Dave
>
> On Wed, Oct 13, 2010 at 4:10 PM, Anjib Mulepati<anji...@hotmail.com> 
wrote:
>
>>   I am not using common-fileupload library so do I have to write extra 
piece
>> of code to delete?
>>
>> Anjib
>>
>>
>>   On 10/13/2010 3:11 AM, Rahul Mohan wrote:
>>
>>>    Does the (temporary!!) files get deleted  automatically? I though 
that
>>>> we have to delete it with some additional code.
>>>> Can any one make clear on this.
>>>>
>>>>   Yes. On upload, the commons-fileupload library creates temporary 
files
>>> on
>>> the disk which are deleted on completion of the request. I found three
>>> mechanisms for deletion in the code - (1) file upload interceptor does 
an
>>> explicit deletion of the files on the return path (after
>>> invocation.invoke() ) (2) the DiskFileItem instances created by
>>> commons-fileupload has a finalize method that deletes the file and (3) 
the
>>> commons-fileupload DiskFileItemFactory has a reference to a reaper 
thread
>>> that deletes all unreferenced files. For the last one, I couldn't find 
the
>>> code, but it was written so in the comments.
>>> =====-----=====-----=====
>>> Notice: The information contained in this e-mail
>>> message and/or attachments to it may contain
>>> confidential or privileged information. If you are
>>> not the intended recipient, any dissemination, use,
>>> review, distribution, printing or copying of the
>>> information contained in this e-mail message
>>> and/or attachments to it are strictly prohibited. If
>>> you have received this communication in error,
>>> please notify us by reply e-mail or telephone and
>>> immediately and permanently delete the message
>>> and any attachments. Thank you
>>>
>>>
>>>
>>>



=====-----=====-----=====
Notice: The information contained in this e-mail
message and/or attachments to it may contain 
confidential or privileged information. If you are 
not the intended recipient, any dissemination, use, 
review, distribution, printing or copying of the 
information contained in this e-mail message 
and/or attachments to it are strictly prohibited. If 
you have received this communication in error, 
please notify us by reply e-mail or telephone and 
immediately and permanently delete the message 
and any attachments. Thank you


Reply via email to