Documentation
¶
Index ¶
- Constants
- Variables
- func AudioCacheDir(ctx context.Context, h string) (string, error)
- func CacheAudioFromBytes(ctx context.Context, h string, data []byte, ext string) (string, error)
- func CacheDocumentFromBytes(ctx context.Context, h string, data []byte, filename string) (string, error)
- func CacheImageFromBytes(ctx context.Context, h string, data []byte, ext string) (string, error)
- func CacheVideoFromBytes(ctx context.Context, h string, data []byte, ext string) (string, error)
- func CleanupAudioCache(ctx context.Context, h string, maxAgeHours float64) (int, error)
- func CleanupDocumentCache(ctx context.Context, h string, maxAgeHours float64) (int, error)
- func CleanupImageCache(ctx context.Context, h string, maxAgeHours float64) (int, error)
- func CleanupScreenshotCache(ctx context.Context, h string, maxAgeHours float64) (int, error)
- func CleanupVideoCache(ctx context.Context, h string, maxAgeHours float64) (int, error)
- func DocumentCacheDir(ctx context.Context, h string) (string, error)
- func ImageCacheDir(ctx context.Context, h string) (string, error)
- func InboundMediaMaxBytes(ctx context.Context, h string) int64
- func SniffAudioExt(data []byte, fallbackExt string) string
- func SniffContainer(data []byte) (string, bool)
- func TranscodeToOggOpus(ctx context.Context, path, bitrate string, timeout time.Duration, ...) (string, error)
- func ValidateInboundMediaSize(ctx context.Context, h string, size int64, mediaType string, maxBytes *int64) error
- func VideoCacheDir(ctx context.Context, h string) (string, error)
- type ValueError
Constants ¶
const DefaultInboundMediaMaxBytes int64 = 128 * 1024 * 1024
Inbound media cap applied when gateway.max_inbound_media_bytes is absent or unparseable
const MediaCacheMaxAgeHours = 24
Age in hours past which the cleanup sweeps delete cached media
Variables ¶
var ContainerToExt = map[string]string{
"m4a": ".m4a", "mp4": ".mp4", "ogg": ".ogg", "flac": ".flac", "wav": ".wav", "mp3": ".mp3", "aac": ".aac", "webm": ".webm",
}
Container id to canonical file extension
var SupportedDocumentTypes = map[string]string{
".pdf": "application/pdf", ".md": "text/markdown", ".txt": "text/plain", ".csv": "text/csv",
".log": "text/plain", ".json": "application/json", ".xml": "application/xml",
".yaml": "application/yaml", ".yml": "application/yaml", ".toml": "application/toml",
".ini": "text/plain", ".cfg": "text/plain", ".zip": "application/zip",
".doc": "application/msword", ".xls": "application/vnd.ms-excel",
".ppt": "application/vnd.ms-powerpoint",
".docx": "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
".xlsx": "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
".pptx": "application/vnd.openxmlformats-officedocument.presentationml.presentation",
".ts": "text/plain", ".py": "text/plain", ".sh": "text/plain",
}
Document extensions the gateway accepts with their MIME types
var SupportedVideoTypes = map[string]string{
".mp4": "video/mp4", ".mov": "video/quicktime", ".webm": "video/webm", ".mkv": "video/x-matroska", ".avi": "video/x-msvideo",
}
Video extensions the gateway accepts with their MIME types
Functions ¶
func AudioCacheDir ¶
Audio cache directory of the home, created on demand
func CacheAudioFromBytes ¶
Caches audio bytes under the container sniffed extension and returns the path
func CacheDocumentFromBytes ¶
func CacheDocumentFromBytes(ctx context.Context, h string, data []byte, filename string) (string, error)
Caches document bytes as doc_uuid12_name with the name sanitized, refusing a path that leaves the cache
func CacheImageFromBytes ¶
Caches image bytes and returns the path, refusing oversized payloads and bytes that are not an image
func CacheVideoFromBytes ¶
Caches video bytes and returns the path, refusing oversized payloads
func CleanupAudioCache ¶
Deletes cached audio older than the age in hours and returns the count
func CleanupDocumentCache ¶
Deletes cached documents older than the age in hours and returns the count
func CleanupImageCache ¶
Deletes cached images older than the age in hours and returns the count
func CleanupScreenshotCache ¶
Deletes cached screenshots older than the age in hours and returns the count
func CleanupVideoCache ¶
Deletes cached videos older than the age in hours and returns the count
func DocumentCacheDir ¶
Document cache directory of the home, created on demand
func ImageCacheDir ¶
Image cache directory of the home, created on demand
func InboundMediaMaxBytes ¶
Inbound media byte cap from the home config, the default when the key is missing or not an integer
func SniffAudioExt ¶
Container matching extension with generic MP4 claimed as m4a, the dotted fallback when unknown
func SniffContainer ¶
Container key from magic bytes, false when the bytes match no audio or AV container
func TranscodeToOggOpus ¶
func TranscodeToOggOpus(ctx context.Context, path, bitrate string, timeout time.Duration, outputPath string) (string, error)
Encodes the file to voip tuned Ogg Opus through ffmpeg, empty when ffmpeg is missing or the encode fails
Types ¶
type ValueError ¶
type ValueError struct{ Msg string }
Error the Python cache functions raise as ValueError
func (*ValueError) Error ¶
func (e *ValueError) Error() string
func (*ValueError) PyTypeName ¶
func (e *ValueError) PyTypeName() string
Python exception class name the error stands for