How to save upload files to another server

后端 未结 2 1690
抹茶落季
抹茶落季 2021-01-22 09:10

I\'m currently using django. And now I need to save a file uploaded by a user to another server which is not the one that serves the django application. The file will be saved

2条回答
  •  深忆病人
    2021-01-22 10:02

    This wont work out of the box, you need to have a mechanism(write some code) to queue the files that are uploaded through django application, then use a middleware(can be in python) to transfer files from queue to your file server. so flow is basically like this:

    1. Accept the uploaded file via django app.
    2. django app. writes the file info(its temporary path and name) to a queue
    3. A middleware app reads the next file in queue.
    4. The middleware app use some transfering protocol(sftp, scp, ftp, http etc...) to copy the file to file server.
    5. Middleware app deletes the file from where django app is hosted so django server dont have a copy of the file.

提交回复
热议问题