feat: remote image preview — detect via magic bytes, download to temp for overlay

This commit is contained in:
vrubelroman 2026-05-13 13:28:19 +03:00
parent 2d6ec2e445
commit fae53d6fd3
3 changed files with 97 additions and 18 deletions

View file

@ -133,7 +133,7 @@ func BuildPreview(entry Entry, options PreviewOptions) Preview {
}
data := buffer.Bytes()
if format, dimensions, ok := detectImage(data); ok {
if format, dimensions, ok := DetectImage(data); ok {
preview.Kind = PreviewKindImage
preview.Metadata.ImageFormat = format
preview.Metadata.ImageSize = dimensions
@ -671,7 +671,7 @@ func buildVideoPreview(entry Entry, options PreviewOptions, base Preview) Previe
return base
}
func detectImage(data []byte) (string, string, bool) {
func DetectImage(data []byte) (string, string, bool) {
cfg, format, err := image.DecodeConfig(bytes.NewReader(data))
if err != nil {
return "", "", false

View file

@ -485,6 +485,11 @@ func (c *SSHClient) CopyFileFromRemote(remotePath, localPath string) error {
return nil
}
// DownloadFile downloads a remote file to a local path via SFTP.
func (c *SSHClient) DownloadFile(remotePath, localPath string) error {
return c.CopyFileFromRemote(remotePath, localPath)
}
// CopyDirToRemote recursively copies a local directory to a remote path.
func (c *SSHClient) CopyDirToRemote(localDir, remoteDir string) error {
return c.copyDirToRemote(localDir, remoteDir, nil, nil)