S
S
sazhyk2016-09-05 14:23:17
Django
sazhyk, 2016-09-05 14:23:17

How to archive Django upload files on the fly?

Tell me how to implement archiving of user-loaded files?
If on the fingers, then the task is as follows:
1. There is a form with
<input type="file" multiupload>
2. The user's files after downloading should be available for download via a link in the form of a single archive.
Maybe there are ready-made solutions? Maybe someone implemented similar - share experience.
PS. I understand that this is not a weak load on the server, but I do not see another solution.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Roman Kitaev, 2016-09-05
@deliro

In order for one user not to stop the work of the entire server, the scheme should look something like this:
1) The user transfers files in the form
2) Janga saves files in the file system and creates a task for Celery
3) Janga gives the user a redirect to the URL. For example, this: /tasks/17d9565387b046c1ba84bdbe55e0b0c8/, on which there is a script that once per second/2/10 throws AJAX requests to the task status URL: /tasks/17d9565387b046c1ba84bdbe55e0b0c8/status/ and either makes the user wait further, or shows the result
-- In the meantime (in parallel) Celery gets to the very task and creates an archive.
4) The user is shown a link to download the archive.
Optionally, you can not redirect the user / assign the rights to view tasks only to the users who created them, and so on. You can even not use Celery, but get by with one subprocess and pipes.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question