Asynchronous File Upload to Amazon S3 with Django

后端 未结 7 1179
轻奢々
轻奢々 2021-01-30 04:18

I am using this file storage engine to store files to Amazon S3 when they are uploaded:

http://code.welldev.org/django-storages/wiki/Home

It takes quite a long t

7条回答
  •  难免孤独
    2021-01-30 04:50

    You could decouple the process:

    • the user selects file to upload and sends it to your server. After this he sees a page "Thank you for uploading foofile.txt, it is now stored in our storage backend"
    • When the users has uploaded the file it is stored temporary directory on your server and, if needed, some metadata is stored in your database.
    • A background process on your server then uploads the file to S3. This would only possible if you have full access to your server so you can create some kind of "deamon" to to this (or simply use a cronjob).*
    • The page that is displayed polls asynchronously and displays some kind of progress bar to the user (or s simple "please wait" Message. This would only be needed if the user should be able to "use" (put it in a message, or something like that) it directly after uploading.

    [*: In case you have only a shared hosting you could possibly build some solution which uses an hidden Iframe in the users browser to start a script which then uploads the file to S3]

提交回复
热议问题