(Transfer) Ideas for uploading files

At first glance, AJAX_UPLOAD is used. When you click on the image, upload it.
If this is the case, then you will need to:
create a temporary directory
AJAX_UPLOAD to the temporary directory
FORM When submitting, mv the temporary directory file to the official directory
and write a scheduled task to clean up the temporary directory. There are many ways to catalog
the temporary directory. If the amount is not large, the date directory is the easiest. In fact, the files in the task


temporary directory of the previous day can be deleted asynchronously, and the value of the space can be deleted, that is to
say, it does not need to rely on the behavior of whether the user submits the form.
There needs to be a thread or process in the entire service to manage this directory.
This thread needs to have 2 functions to
regularly detect the number of files in the directory/directory space
and give a threshold. When the number of files in the directory is sorted by the creation time of the file, delete the oldest one. Documents, the number of deletions can be given a percentage to give a suggestion
for this feature design involving asynchronous file uploads.
Idea:
first upload the file to the server, and save a piece of related data to the database, the status is marked as - (not enabled) and set the expiration time, and at the same time, the url of the file upload is fed back to the client, and the echo is realized
when the user submits the form After that, update the status flag of the previously uploaded file to ---- has taken effect
. If the user does not submit the form, the file has reached the expiration time, and the java program can be used to delete the expired file (not effective and expired)

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326640660&siteId=291194637