sftp上传到不存在的目录

sftp uploading to non-existing directory

假设我必须使用 sftp

上传文件 dir-a/dir-b/dir-c/xxx.txt
  1. 我应该先创建目标目录吗?
  2. 我应该在复制文件之前打开目标目录吗?
  3. 如果必须创建此路径 dir-a/dir-b/dir-c - 是一个命令还是三个?

Should I create the target directory first?

通常是的。 SFTP 服务器通常不创建父目录。但是先试到底有多难?

Should I open target directory before copying the file?

你不必。 put 命令确实接受 remote-path,它可以是相对于远程工作目录的绝对目录或相对目录。

If have to create this path dir-a/dir-b/dir-c - is it one command or three?

这是三个命令:

mkdir dir-a/
mkdir dir-a/dir-b/
mkdir dir-a/dir-b/dir-c