feat: add SFTP drag-and-drop file handling and upload functionality

- Implemented drag-and-drop support for file uploads in the terminal.
- Added a modal for users to choose between uploading files or pasting contents.
- Enhanced SFTP browser with a directory picker for selecting upload destinations.
- Introduced methods for handling file uploads and reading file contents from the local system.
- Added a new API endpoint for uploading raw file data to the server.
- Implemented session management improvements to retrieve the current working directory for SSH sessions.
- Updated documentation to include an overview and quick start guide for Nexus Terminal.
This commit is contained in:
Andy Dixon
2026-04-21 13:20:03 +01:00
parent 7146063da2
commit 2ce145ba0f
13 changed files with 1349 additions and 560 deletions
+20
View File
@@ -8,6 +8,7 @@
package sftpclient
import (
"bytes"
"fmt"
"io"
"os"
@@ -247,6 +248,25 @@ func (c *Client) Upload(localPath, remotePath string, onProgress func(TransferPr
return c.copyWithProgress(local, remote, totalSize, remotePath, onProgress)
}
// UploadBytes writes in-memory data to a remote file path.
func (c *Client) UploadBytes(remotePath string, data []byte, onProgress func(TransferProgress)) error {
c.mu.Lock()
if c.closed || c.sftp == nil {
c.mu.Unlock()
return fmt.Errorf("sftpclient: client is closed")
}
remote, err := c.sftp.Create(remotePath)
if err != nil {
c.mu.Unlock()
return fmt.Errorf("sftpclient: failed to create remote file: %w", err)
}
c.mu.Unlock()
defer remote.Close()
reader := bytes.NewReader(data)
return c.copyWithProgress(reader, remote, int64(len(data)), remotePath, onProgress)
}
// Pwd returns the current working directory on the remote host.
func (c *Client) Pwd() (string, error) {
c.mu.Lock()