1

I have a Spring Webflow application. In one view-state a user can upload file to server. By default, file is created temporarily by Apache Trinidad only for request scope. So I copy it to another path on server because we need user confirmation in next step. After copying, file is persisted on server disk storage and reference is .

<!-- This variable holds server File path
<var name="uploadFO" class="com.company.whateverUploadFO" />
...
<!-- User uploads file here in <tr:inputFile> element -->
<view-state id="view" view="/flow/upload.xhtml">
    <transition on="reset" to="deleteFile"/>
    <transition on="start" to="startProcessing"/>
</view-state>

In normal flow, file will be deleted explicitly. But there is a problem. What if user closes browser after upload and before confirmation? File will be left on server disk "forever". How can I prevent this? How can I register some clean-up method called when user abandons flow? Thank you

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
Gondy
  • 4,925
  • 4
  • 40
  • 46

1 Answers1

0

When a user exits his browser, no end state is called. So it's not possible to delete it nicely when he exits his browser. You could use a job that cleans up your resources each minute/hour/day/... or mayby you should rethink you solution and delete the file directly after you uploaded it?

Tom Jonckheere
  • 1,630
  • 3
  • 20
  • 37