streaming images, audio, and video

This commit is contained in:
sawka
2024-05-16 22:48:23 -07:00
parent d34ccfd7ab
commit 146bade6f1
8 changed files with 115 additions and 15 deletions
+5
View File
@@ -13,6 +13,8 @@ import (
"github.com/wavetermdev/thenextwave/pkg/wavebase"
)
const MaxFileSize = 10 * 1024 * 1024 // 10M
type FileService struct{}
type FileInfo struct {
@@ -58,6 +60,9 @@ func (fs *FileService) ReadFile(path string) (*FullFile, error) {
if finfo.NotFound {
return &FullFile{Info: finfo}, nil
}
if finfo.Size > MaxFileSize {
return nil, fmt.Errorf("file %q is too large to read, use /wave/stream-file", path)
}
cleanedPath := filepath.Clean(wavebase.ExpandHomeDir(path))
barr, err := os.ReadFile(cleanedPath)
if err != nil {