sshnet / sshnet/SSH.NET

How can I force creation of the file on upload even if the directory does not exist

Open
#962 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C#
Stars
4.4k
Forks
993
Avg merge
9d 21h
Merged PRs (30d)
1

Description

How can I force the creation of the file on upload even if the directory does not exist something similar creating file and recursively creating directories

using (SftpClient sftp = new SftpClient(ipSftpServer, portSftpServer, userSftp, passSftp))
  {
      sftp.Connect();
      memoryStream.Seek(0, SeekOrigin.Begin);
      sftp.UploadFile(memoryStream, '/var/local/dcm4chee-arc/wildfly/data/fs1/2021/02/01/0A06A0AF/0DECCF06/F96DE23E".dcm', 
delegate (ulong d)
      {
          if(uploadCallback != null)
          {
              uploadCallback((long)d, bytesTotal);
          }
      });                           
      Console.WriteLine($"end of file copy");
      sftp.Disconnect();
  }

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Begin with the SftpClient.UploadFile call shown in the issue and review the SFTP path and parent-directory behavior in the public API documentation. Done would be a supported way to upload when the nested destination directory is absent, with the expected behavior verified for the path shown.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
networking
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.