I’ve discovered one more thing. As I’m working with a very restrictive SFTP server, it doesn’t let me implicitly create directories.
Use case:
set Operation to Upload
set Path to /foo/bar.txt (where foo doesn’t exist yet)
set random content (not important here)
If “foo” doesn’t exist, I’ll get the following error:
ERROR: _mkdir: Permission denied /import/docs/x/
Error: _mkdir: Permission denied /import/docs/x/
at Object.formatError (/Users/frane/workspace/n8n/node_modules/ssh2-sftp-client/src/utils.js:62:18)
at /Users/frane/workspace/n8n/node_modules/ssh2-sftp-client/src/index.js:871:21
at SFTPStream._transform (/Users/frane/workspace/n8n/node_modules/ssh2-streams/lib/sftp.js:417:17)
at SFTPStream.Transform._write (node:internal/streams/transform:184:23)
at writeOrBuffer (node:internal/streams/writable:388:12)
at SFTPStream.Writable.write (node:internal/streams/writable:333:10)
at Channel.ondata (node:internal/streams/readable:715:22)
at Channel.emit (node:events:327:20)
at addChunk (node:internal/streams/readable:304:12)
at readableAddChunk (node:internal/streams/readable:279:9)
at Channel.Readable.push (node:internal/streams/readable:218:10)
at SSH2Stream.<anonymous> (/Users/frane/workspace/n8n/node_modules/ssh2/lib/Channel.js:167:15)
at SSH2Stream.emit (node:events:327:20)
at parsePacket (/Users/frane/workspace/n8n/node_modules/ssh2-streams/lib/ssh.js:3191:10)
at SSH2Stream._transform (/Users/frane/workspace/n8n/node_modules/ssh2-streams/lib/ssh.js:701:13)
at SSH2Stream.Transform._write (node:internal/streams/transform:184:23)
If “foo” exists then everything runs fin and the upload performs as id should.
I think it would be greatly beneficial to export a couple of more common FTP operations, like “mkdir”, “rm” or “mv”.
In my case that would solve the issue as I’d be able to create the dir first and then upload the file to it.
This is quite weird as the node it’s supposed to do that for you (Create the folder in case it does not exist). Just tested and it’s working just fine for me.
It seems that the Windows-based SFTP that I have to work with is very sensitive. When calling mkdir there was always a trailing slash, e.g. /foo/bar/ which was rejected, but mkdir /foo/bar works.