_put(lPath, rPath, opts, addListeners = true) {
    let listeners, wtr, rdr;
    return new Promise((resolve, reject) => {
      if (addListeners) {
        listeners = addTempListeners(this, '_put', reject);
      }
      opts = {
        readStreamOptions: { ...opts?.readStreamOptions, autoClose: true },
        writeStreamOptions: { ...opts?.writeStreamOptions, autoClose: true },
        pipeOptions: { ...opts?.pipeOptions, end: true },
      };
      if (haveConnection(this, '_put', reject)) {
        wtr = this.sftp.createWriteStream(rPath, opts.writeStreamOptions);
        wtr.once('error', (err) => {
          if (typeof lPath === 'string' && rdr && !rdr.destroyed) {
            rdr.destroy();
          }
          reject(
            this.fmtError(
              `Write stream error: ${err.message} ${rPath}`,
              '_put',
              err.code,
            ),
          );
        });
        wtr.once('close', () => {
          resolve(`Uploaded data stream to ${rPath}`);
        });
        if (lPath instanceof Buffer) {
          this.debugMsg('put source is a buffer');
          wtr.end(lPath);
        } else {
          if (typeof lPath === 'string') {
            this.debugMsg('put source is string path');
            rdr = fs.createReadStream(lPath, opts.readStreamOptions);
          } else {
            this.debugMsg('put source is a stream');
            rdr = lPath;
          }
          rdr.once('error', (err) => {
            reject(
              this.fmtError(
                `Read stream error: ${err.message} ${
                  typeof lPath === 'string' ? lPath : '<stream>'
                }`,
                '_put',
                err.code,
              ),
            );
          });
          rdr.pipe(wtr, opts.pipeOptions);
        }
      }
    }).finally(() => {
      if (wtr && !wtr.destroyed) {
        wtr.destroy();
      }
      if (addListeners) {
        removeTempListeners(this, listeners, '_put');
      }
    });
  }
Create a file on the remote server. The 'src' argument
can be a buffer, string or read stream. If 'src' is a string, it
should be the path to a local file.

@param  {String|Buffer|stream} localSrc - source data to use
@param  {String} remotePath - path to remote file
@param  {Object} options - options used for read, write stream and pipe configuration
                           value supported by node. Allowed properties are readStreamOptions,
                           writeStreamOptions and pipeOptions.

*Important Note*: The ability to set ''autoClose' on read/write streams and 'end' on pipe() calls
is no longer supported. New methods 'createReadStream()' and 'createWriteStream()' have been
added to support low-level access to stream objects.

@return {Promise<String>}