first commit

This commit is contained in:
2025-09-08 13:27:09 -04:00
commit 41eb06d247
21 changed files with 1471 additions and 0 deletions

31
utils/encoder.go Normal file
View File

@@ -0,0 +1,31 @@
package utils
import (
"encoding/base64"
"fmt"
"io"
"os"
"strings"
)
// mp3ToBase64 reads an MP3 file and returns its base64-encoded content
func Mp3ToBase64(filePath string) (string, error) {
file, err := os.Open(filePath)
if err != nil {
return "", fmt.Errorf("failed to open MP3 file: %v", err)
}
defer file.Close()
// Verify file is an MP3
if !strings.HasSuffix(strings.ToLower(filePath), ".mp3") {
return "", fmt.Errorf("file is not an MP3: %s", filePath)
}
data, err := io.ReadAll(file)
if err != nil {
return "", fmt.Errorf("failed to read MP3 file: %v", err)
}
encoded := base64.StdEncoding.EncodeToString(data)
return encoded, nil
}