Django file upload with FTP backend

后端 未结 2 884
天涯浪人
天涯浪人 2021-02-04 18:34

I want to upload my files based on the example Need a minimal Django file upload example, however I want to store the files not locally, but on another server with the use of FT

相关标签:
2条回答
  • 2021-02-04 19:11

    Try this

    models.py

    from storages.backends.ftp import FTPStorage
    fs = FTPStorage()
    

    settings.py

    DEFAULT_FILE_STORAGE = 'storages.backends.ftp.FTPStorage'
    FTP_STORAGE_LOCATION = 'ftp://user:password@localhost:21'
    
    0 讨论(0)
  • 2021-02-04 19:20

    It looks like your import is wrong. If the file is named ftp.py the import should be:

    from ftp import FTPStorage
    

    Depending on where the file is relatively to your PYTHONPATH you might need to add more, e.g.:

    from your_app.ftp import ...
    
    0 讨论(0)
提交回复
热议问题