load README.md into preview view

This commit is contained in:
sawka
2024-05-14 12:29:41 -07:00
parent 1db615bb3a
commit 91a3394602
13 changed files with 86 additions and 12 deletions
+10 -2
View File
@@ -4,14 +4,22 @@
package fileservice
import (
"encoding/base64"
"fmt"
"os"
"time"
"github.com/wavetermdev/thenextwave/pkg/wavebase"
)
type FileService struct{}
func (fs *FileService) ReadFile(path string) ([]byte, error) {
func (fs *FileService) ReadFile(path string) (string, error) {
path = wavebase.ExpandHomeDir(path)
return os.ReadFile(path)
barr, err := os.ReadFile(path)
if err != nil {
return "", fmt.Errorf("cannot read file %q: %w", path, err)
}
time.Sleep(2 * time.Second)
return base64.StdEncoding.EncodeToString(barr), nil
}