Paramiko put方法将抛出“ [[Errno 2]文件未找到””。 SFTP服务器是否触发了上传后自动移动文件 [英] Paramiko put method throws "[Errno 2] File not found" if SFTP server has trigger to automatically move file upon upload

查看:371
本文介绍了Paramiko put方法将抛出“ [[Errno 2]文件未找到””。 SFTP服务器是否触发了上传后自动移动文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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

[Errno 2]下面找不到文件错误。

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_transfer\TransferFiles.py", line 123, in main
  File "paramiko\sftp_client.py", line 727, in put
  File "paramiko\sftp_client.py", line 689, in putfo
  File "paramiko\sftp_client.py", line 460, in stat
  File "paramiko\sftp_client.py", line 780, in _request
  File "paramiko\sftp_client.py", line 832, in _read_response
  File "paramiko\sftp_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.

文件实际上可以正确上传,因此我可以捕获Exception并忽略该错误。

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.

为避免检查,设置确认参数rel = nofollow noreferrer> SFTPClient.put False

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]文件未找到””。 SFTP服务器是否触发了上传后自动移动文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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