0

I am trying to make Jquery File Upload to work and I'd like an advice about storing the files and particularly I am concerned about the situation when a user chooses a few files so they get downloaded to the server and then user just closes the browser or the tab or whatever, so I have extra files on my server which wont be used and therefore I will have to come up with something to remove these extra files... So the question is, how is it usually handled? What's the 'best practice' ?

btw, I am using ruby on rails and carrierwave, if that matters

NoDisplayName
  • 15,246
  • 12
  • 62
  • 98
  • You can write a script on the server that will delete all the unused files on the server at a specified time interval. – ankur140290 Jan 27 '14 at 05:43
  • yeah, thats what I am thinking about, but maybe somebody can offer something better – NoDisplayName Jan 27 '14 at 05:49
  • You can add a code that will not allow user to close/quit the browser once the file is uploaded and then delete his/her files on his conformation. – ankur140290 Jan 27 '14 at 06:57
  • 1
    I think that can be kinda obtrusive – NoDisplayName Jan 27 '14 at 09:42
  • This is obstructive but it will avoid a situation where a user has closed the browser/tab by mistake. And usually many sites does that when user is in the mid of something and closes the browser/tab then it displays warning to the user for conformation... – ankur140290 Jan 27 '14 at 12:01
  • yeah, proably you're right, I'll try to do that and see how it looks, thanks – NoDisplayName Jan 27 '14 at 12:13

1 Answers1

2

Apart from running a websocket script (to check when the user closes the browser), I feel the most efficient way to do this is to run a scheduled task

Images

It will all hinge on how you'll associate your images with resources on your server. For example, if the images are meant to be used in a piece of content (which is not saved), you can check for the existence of the content, and delete any image which has no association

Like many software systems, the "best practice" will only become apparent if you detail some context to your query. For example -- what are the images for & how will they be managed?

Community
  • 1
  • 1
Richard Peck
  • 76,116
  • 9
  • 93
  • 147