Skip to content

c.put confusion about string vs file-like object in local #1749

@peteruhnak

Description

@peteruhnak

According to transfer.put() docs, I should be able to either provide local path to a file (as a string), or a file-like object.

When using the former (string), I can specify in the remote path only the target directory. This is used in some examples:

c.put('myfiles.tgz', '/opt/mydata')

But when I try to do the same ( c.put('file.txt', '/home/me/dir'), I always end up with IOError: Failure, because it is actually behaving as if the local path was a file-like object and not a string.

It fails specifically on paramiko.transport.sftp.sftp._log: [chan 0] open('/home/me/dir', 'wb')

The solution is to always provide the full path, e.g.

c.put('file.txt', '/home/me/dir/file.txt')

But that is inconsistent with the docs and examples.

Finally, having to provide the full path to $HOME is less than ideal, but there seems to be issue for that already #1653

  • Tested in Windows 10
  • Fabric 2.0.0
  • Paramiko 2.4.1
  • Invoke 1.0.0

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions