1
  1. Using Struts 2: when will the .tmp file - that gets created after uploading a file - be deleted?

  2. How can you customize when the .tmp file should be deleted? Do you have to create a copy of it?

Please don't be shy to give some code :)

  • refer this link http://stackoverflow.com/questions/10229328/while-trying-to-upload-the-image-in-struts2-the-image-is-not-uploading-msg-unabl – MohanaRao SV Jun 21 '12 at 19:22
  • I don't think people are shy about giving code! They just need to know that people asking questions have written some codes for themselves. – Alex Barnes Jun 21 '12 at 19:25

1 Answers1

2

1. This depends on which version of S2 you're talking about.

  • S2.2.1 and prior: the file upload interceptor deleted temp files.
  • S2.2.3 and above: the filter dispatchers start the deletion process, changed due to WW-3490.

2. Assuming you're using a recent version, it might be possible to inject a tweaked Dispatcher, although it's not immediately obvious how–if it is, that's the easiest change at the core level.

The easiest approach from a practical standpoint is to copy files in the action, which is also pretty fast on any reasonable file system.

Dave Newton
  • 158,873
  • 26
  • 254
  • 302
  • I have used S2.3.15.2 In My application . But when i am going to upload any file its create many `.tmp` with file 1KB size in my temp folder of tomcat and its not deleted automatically . SO why this happen ? I want to delete this all temp file . – HybrisHelp Oct 22 '13 at 13:44
  • @ankit337 No idea, it shouldn't, if you're not uploading many 1K files. If you're having a specific issue, please ask a new question, providing all relevant configuration, action, etc. details. – Dave Newton Oct 22 '13 at 14:18