first commit
This commit is contained in:
14
core/providers/utils/file.go
Normal file
14
core/providers/utils/file.go
Normal file
@@ -0,0 +1,14 @@
|
||||
package utils
|
||||
|
||||
import (
|
||||
"encoding/base64"
|
||||
"fmt"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
// FileBytesToBase64DataURL converts raw file bytes to base64 data URL format
|
||||
func FileBytesToBase64DataURL(fileBytes []byte) string {
|
||||
mimeType := http.DetectContentType(fileBytes)
|
||||
b64Data := base64.StdEncoding.EncodeToString(fileBytes)
|
||||
return fmt.Sprintf("data:%s;base64,%s", mimeType, b64Data)
|
||||
}
|
||||
Reference in New Issue
Block a user