• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Delete file when the file downloaded.

 
Ranch Hand
Posts: 80
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have to implement a functionality - delete the file on server when user download file is complete. we do not want store that file on server anymore.

I m using struts2 for downloading file on tomcat server. How can i identify file downloading is complete. as of now, i can download file successfully but when the file should be deleted?

code in action class:


struts.xml
-----------------
 
Ranch Hand
Posts: 485
Eclipse IDE Firefox Browser Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
write a custom interceptor to delete the file and make sure that this will be executed only after successful completion of downloading file. Ask me if you have any doubts.
 
vikas byn
Ranch Hand
Posts: 80
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
is there any way, to identify end of stream?
 
Ranch Hand
Posts: 41
Eclipse IDE Firefox Browser Tomcat Server
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Mind using AJAX? Here's a comprehensive solution that you can relate your question to. Here's a bit more insight into the same. Or even this could be of some help.

Not into AJAX? The following code snippet in your servlet is supposed to let you know if the download has completed.

Supposedly, the file download will be completed as soon as the while loop is exited.
Hope that helps.
 
vikas byn
Ranch Hand
Posts: 80
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Mohana Rao wrote:write a custom interceptor to delete the file and make sure that this will be executed only after successful completion of downloading file. Ask me if you have any doubts.



actually I am not sure about Interceptor is the good idea. Intercept just intercept the Action execution. It will not have information when the end of stream occurred. Browser transfer files over http So i think there is something different kind of solution.
 
Mohana Rao Sv
Ranch Hand
Posts: 485
Eclipse IDE Firefox Browser Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Interceptors are objects that dynamically intercept Action invocations. They provide the developer with the opportunity to define code that can be executed before and/or after the execution of an action. They also have the ability to prevent an action from executing. Interceptors provide developers a way to encapulate common functionality in a re-usable form that can be applied to one or more Actions. So, write an interceptor which is responsible for deleting the file. It(Interceptors) will not be called until and unless you result execution is successful.
 
vikas byn
Ranch Hand
Posts: 80
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Mohana Rao wrote: Interceptors are objects that dynamically intercept Action invocations. They provide the developer with the opportunity to define code that can be executed before and/or after the execution of an action. They also have the ability to prevent an action from executing. Interceptors provide developers a way to encapulate common functionality in a re-usable form that can be applied to one or more Actions. So, write an interceptor which is responsible for deleting the file. It(Interceptors) will not be called until and unless you result execution is successful.



thanks for your help.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic