0

我正在尝试将我的 Django 文件存储移动到外部服务器,通过以太网连接到小型本地网络。此本地网络未连接到 Internet。我现在正在为我的文件字段使用 django-storages SFTPStorage。服务器运行良好,但在尝试上传文件时,出现以下错误:

Performing system checks...

System check identified no issues (0 silenced).
August 20, 2021 - 13:23:22
Django version 3.2.4, using settings 'smartlab.settings'
Starting ASGI/Channels version 3.0.3 development server at http://127.0.0.1:8000/
Quit the server with CONTROL-C.
Traceback (most recent call last):
  File "/home/smartlab/larc-smartlab/venv/lib/python3.9/site-packages/storages/backends/sftpstorage.py", line 115, in _mkdir
    self._mkdir(parent)
  File "/home/smartlab/larc-smartlab/venv/lib/python3.9/site-packages/storages/backends/sftpstorage.py", line 115, in _mkdir
    self._mkdir(parent)
  File "/home/smartlab/larc-smartlab/venv/lib/python3.9/site-packages/storages/backends/sftpstorage.py", line 115, in _mkdir
    self._mkdir(parent)
  [Previous line repeated 2 more times]
  File "/home/smartlab/larc-smartlab/venv/lib/python3.9/site-packages/storages/backends/sftpstorage.py", line 114, in _mkdir
    if not self.exists(parent):
  File "/home/smartlab/larc-smartlab/venv/lib/python3.9/site-packages/storages/backends/sftpstorage.py", line 151, in exists
    self.sftp.stat(self._remote_path(name))
  File "/home/smartlab/larc-smartlab/venv/lib/python3.9/site-packages/storages/backends/sftpstorage.py", line 87, in sftp
    self._connect()
  File "/home/smartlab/larc-smartlab/venv/lib/python3.9/site-packages/storages/backends/sftpstorage.py", line 61, in _connect
    self._ssh.load_host_keys(known_host_file)
  File "/home/smartlab/larc-smartlab/venv/lib/python3.9/site-packages/paramiko/client.py", line 127, in load_host_keys
    self._host_keys.load(filename)
  File "/home/smartlab/larc-smartlab/venv/lib/python3.9/site-packages/paramiko/hostkeys.py", line 101, in load
    e = HostKeyEntry.from_line(line, lineno)
  File "/home/smartlab/larc-smartlab/venv/lib/python3.9/site-packages/paramiko/hostkeys.py", line 364, in from_line
    key = ECDSAKey(data=decodebytes(key), validate_point=False)
  File "/home/smartlab/larc-smartlab/venv/lib/python3.9/site-packages/paramiko/ecdsakey.py", line 163, in __init__
    key = ec.EllipticCurvePublicKey.from_encoded_point(
  File "/home/smartlab/larc-smartlab/venv/lib/python3.9/site-packages/cryptography/hazmat/primitives/asymmetric/ec.py", line 191, in from_encoded_point
    if not isinstance(curve, EllipticCurve):
  File "/usr/lib/python3.9/abc.py", line 98, in __instancecheck__
    return _abc_instancecheck(cls, instance)
RecursionError: maximum recursion depth exceeded in comparison
Request resulted in error: maximum recursion depth exceeded in comparison

在 settings.py 中,我有以下内容:

DEFAULT_FILE_STORAGE = 'storages.backends.sftpstorage.SFTPStorage'
SFTP_STORAGE_HOST = '192.168.1.103'
SFTP_STORAGE_ROOT = '/home/smartlab/larc-smartlab/media'
SFTP_STORAGE_PARAMS = {
   "username": "[username on remote]",
   "password": "[password on remote]"
}

在我的模型上,我有这样的字段:

from storages.backends.sftpstorage import SFTPStorage
...
image = models.ImageField(null=True, storage=SFTPStorage())

我正在使用这些软件包的以下版本:

密码学=3.4.7

帕拉米科=2.7.2

django-storages=1.11.1

django=3.2.4

我到处寻找有同样问题的人,但似乎什么都没有。关于为什么在密码学中发生这种递归的任何想法?如何设置我的 SFTP 存储来解决此问题?谢谢!

4

0 回答 0