Subject: sftp upload file path

sftp upload file path

From: William Shipley <william_at_schuylerhouse.com>
Date: Fri, 4 Jan 2019 12:38:54 -0800

I'm a newbie on a steep learning curve with SFTP in general. I am trying to implement libssh2 SFTP file upload to a CrushFTP server. Working with a slightly edited version of the sftp_write.c example, I find that if I call libssh2_sftp_open() with the path "newdir/file.txt" and the directory newdir exists in my FTP server's root, then I will get the file uploaded just fine.

If newdir does not exist, libssh2_sftp_open() function still succeeds and gives me a handle and a 0 libssh2_sftp_last_error() value, but when I call libssh2_sftp_write, I get an error -31 (ERROR_SFTP_PROTOCOL) on the function with status 4 (LIBSSH2_FX_FAILURE) as the libssh2_sftp_last_error(). No file is created.

I'm surprised that libssh2_sftp_open() apparently works but I cannot write to the file. Is there something else I should have checked?

What is the best practice approach for uploading a path with sub-directories that may not exist?

William Shipley
Schuyler House

_______________________________________________
libssh2-devel https://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel
Received on 2019-01-04