Skip to content

asyncssh.sftp.SFTPError: Failure on open() with pflags_or_mode=FXF_CREAT #271

@shsimeonova

Description

@shsimeonova

Hello Ron!

I'm trying to figure out how to upload a file without having it first locally on my machine. My case is i'm receiving file bytes and i want to send those bytes to my sftp server and upload as file in a specific path. From what i read in the source the put() method uploads files only by local path, so i figured out maybe the open() method would do me a favour. I'm currently trying this:

@classmethod
    async def put_file(cls, file_bytes, remote_path, credentials):
        conn = await cls.connect(credentials)

        async with conn.start_sftp_client() as sftp_client:
            try:
                file = await sftp_client.open(remote_path, pflags_or_mode=FXF_CREAT)
                await file.write(file_bytes)
            except asyncssh.SFTPError as err:
                return None

and im getting

asyncssh.sftp.SFTPError: Failure

Thank you in advance! :)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions