utils

package
v0.1.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 17, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DownloadFile

func DownloadFile(url, filename string, opts DownloadOptions) string

DownloadFile downloads a file from URL to a local temp directory. Returns the local file path or empty string on error.

func DownloadFileSimple

func DownloadFileSimple(url, filename string) string

DownloadFileSimple is a simplified version of DownloadFile without options

func IsAudioFile

func IsAudioFile(filename, contentType string) bool

IsAudioFile checks if a file is an audio file based on its filename extension and content type.

func SanitizeFilename

func SanitizeFilename(filename string) string

SanitizeFilename removes potentially dangerous characters from a filename and returns a safe version for local filesystem storage.

func Truncate

func Truncate(s string, maxLen int) string

Truncate returns a truncated version of s with at most maxLen runes. Handles multi-byte Unicode characters properly. If the string is truncated, "..." is appended to indicate truncation.

Types

type DownloadOptions

type DownloadOptions struct {
	Timeout      time.Duration
	ExtraHeaders map[string]string
	LoggerPrefix string
}

DownloadOptions holds optional parameters for downloading files

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL