E
E
Egor2015-12-29 00:52:12
Node.js
Egor, 2015-12-29 00:52:12

Node.js Uploading files to the server. What to do with old unsaved files?

Greetings.
Server on Node.js. Express 4.0 is used.
There is a page with a form on it through which files are loaded. After downloading, the files are placed in a temporary folder temp (for each user a separate temp folder). If the user clicks the Save button, the files will be moved to the user's folder.
Question: if the user uploaded files, but did not click Save, but simply left the page. What to do with these downloaded files in the temp folder ? How to trace such files and delete them?

Answer the question

In order to leave comments, you need to log in

4 answer(s)
V
Vladlen Grachev, 2015-12-29
@gwer

Decide on the time after which the files should be deleted. Periodically clean out obsolete files with a script. In order not to drive through a huge directory tree, when loading a file, you can make a record of the path to it and the time it was loaded into the database. Accordingly, from the database and take a list of files to be deleted (selection by creation / expiration time). Well, do not forget to delete records from the database in the process of bypassing it with a script and when the user clicks the "Save" button, that is, along with deleting the file from the directory.

K
Konstantin Kitmanov, 2015-12-29
@k12th

By cron rm -rf /path/to/users/files/*/*

A
Artur Karapetyan, 2017-05-25
@Secret73

OwlCarousel and don't worry

V
Vitaly Rybchenko, 2017-05-25
@biovr

Use jquery, a method that fires when the window is resized

$(window).resize(function() {
    var dw = $(document).width();
    //твой код
});
</script>

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question