0

Django ファイル ストレージを、イーサネット経由で小さなローカル ネットワークに接続された外部サーバーに移動しようとしています。このローカル ネットワークはインターネットに接続されていません。現在、ファイル フィールドに 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

paramiko=2.7.2

ジャンゴ ストレージ = 1.11.1

ジャンゴ=3.2.4

私は同じ問題を抱えている人を探しましたが、そこには何もないようです. この再帰が暗号化で起こっている理由について何か考えはありますか? これを修正するために SFTP ストレージを設定するにはどうすればよいですか? ありがとう!

4

0 に答える 0