使用Paramiko将PIL图像保存到SFTP文件夹(PNG或PDF)
我需要您的帮助,使用以下示例将 PIL“图像”保存到服务器(SFTP):
transport = paramiko.Transport((host, port))
transport.connect(username=user, password=pwd)
sftp = paramiko.SFTPClient.from_transport(transport)
w, h = 220, 190
image = Image.new("RGB", (w, h))
file = sftp.file("/volume/file.png", "w", -1) # the volume folder is located in the server
file.write(image)
file.flush()
但它不起作用。
I need your help to save a PIL "image" to a server (SFTP) using the following example:
transport = paramiko.Transport((host, port))
transport.connect(username=user, password=pwd)
sftp = paramiko.SFTPClient.from_transport(transport)
w, h = 220, 190
image = Image.new("RGB", (w, h))
file = sftp.file("/volume/file.png", "w", -1) # the volume folder is located in the server
file.write(image)
file.flush()
But it does not work.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我相信你应该使用
图像。 save
:有关
32768
参数的用途,请参阅写入使用 Paramiko/pysftp“打开”方法打开的 SFTP 服务器上的文件很慢。I believe you should use
Image.save
:For the purpose of the
32768
parameter, see Writing to a file on SFTP server opened using Paramiko/pysftp "open" method is slow.