struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Anjib Mulepati <anji...@hotmail.com>
Subject Re: Store permanently file in temp directory
Date Wed, 13 Oct 2010 20:32:03 GMT
  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<anjibcs@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
>>>
>>>
>>>
>>>


Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message