Paramiko put 方法抛出“[Errno 2] File not found";如果 SFTP 服务器已触发在上传时自动移动文件 [英] Paramiko put method throws "[Errno 2] File not found" if SFTP server has trigger to automatically move file upon upload

查看:52
本文介绍了Paramiko put 方法抛出“[Errno 2] File not found";如果 SFTP 服务器已触发在上传时自动移动文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在调用 Paramiko sftp_client.put(locapath,remotepath) 方法

I'm calling the Paramiko sftp_client.put(locapath,remotepath) method

这会引发下面的 [Errno 2] File not found 错误.

This is throwing the [Errno 2] File not found error below.

01/07/2020 01:12:03 PM - ERROR - [Errno 2] File not found
Traceback (most recent call last):
  File "file_transferTransferFiles.py", line 123, in main
  File "paramikosftp_client.py", line 727, in put
  File "paramikosftp_client.py", line 689, in putfo
  File "paramikosftp_client.py", line 460, in stat
  File "paramikosftp_client.py", line 780, in _request
  File "paramikosftp_client.py", line 832, in _read_response
  File "paramikosftp_client.py", line 861, in _convert_status

尝试了许多其他推荐的修复程序后,我发现该错误是由于服务器具有自动触发器,可在文件上传后立即将文件移动到另一个位置.

Having tried many of the other recommend fixes I found that the error is due to the server having an automatic trigger to move the file immediately to another location upon the file being uploaded.

我还没有看到与此问题相关的另一篇文章,我想知道是否有其他人解决了这个问题,因为 SFTP 服务器归第三方所有并且不想更改触发器属性.

I've not seen another post relating to this issue and wanted to know if anyone else has fixed this as the SFTP server is owned by a third party and not wanting to change trigger attributes.

文件实际上正确上传,因此我可以捕获异常并忽略错误.但如果可能的话,我更愿意处理它.

The file actually uploads correctly, so I could catch the Exception and ignore the error. But I'd prefer to handle it, if possible.

推荐答案

Paramiko 默认在上传后验证上传文件的大小.

Paramiko by default verifies a size of the uploaded file after the upload.

如果文件在上传后立即移走,则检查失败.

If the file is moved away immediately after upload, the check fails.

为了避免检查,设置SFTPClient.putFalse.

To avoid the check, set confirm parameter of SFTPClient.put to False.

sftp_client.put(localpath, remotepath, confirm=False)

我相信无论如何检查都是多余的,请参阅
如何在 SFTP 文件传输期间执行校验和以确保数据完整性?

I believe the check is redundant anyway, see
How to perform checksums during a SFTP file transfer for data integrity?

有关 pysftp(Paramiko 的包装器是什么)的类似问题,请参阅:
Python pysftp.put 引发没有这样的文件"尽管文件已上传,但异常

For a similar question about pysftp (what is a wrapper around Paramiko), see:
Python pysftp.put raises "No such file" exception although file is uploaded

这篇关于Paramiko put 方法抛出“[Errno 2] File not found";如果 SFTP 服务器已触发在上传时自动移动文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆