module MediaFilter
Defined in:
utils/media_filter.crConstant Summary
-
MAX_FILE_SIZE =
begin if size_str = ENV["NOIR_MAX_FILE_SIZE"]? parsed = MediaFilter.parse_size(size_str) parsed > 0 ? parsed : (10 * 1024) * 1024 else (10 * 1024) * 1024 end rescue (10 * 1024) * 1024 end
-
Maximum file size for processing (default 10MB). Can be overridden with the environment variable NOIR_MAX_FILE_SIZE. Supported formats for NOIR_MAX_FILE_SIZE:
- Plain bytes integer (e.g., 5242880)
- Human-readable with unit suffix (K, KB, M, MB, G, GB) e.g., 5MB, 500K, 1G Invalid / unparsable values fall back to the default (10MB).
-
MEDIA_EXTENSIONS =
[".jpg", ".jpeg", ".png", ".gif", ".bmp", ".webp", ".tiff", ".svg", ".ico", ".psd", ".raw", ".cr2", ".nef", ".orf", ".sr2", ".heic", ".heif", ".mp4", ".avi", ".mkv", ".mov", ".wmv", ".flv", ".webm", ".m4v", ".mpg", ".mpeg", ".3gp", ".vob", ".rm", ".rmvb", ".asf", ".ogv", ".mp3", ".wav", ".flac", ".aac", ".ogg", ".wma", ".m4a", ".ape", ".ac3", ".dts", ".opus", ".amr", ".au", ".ra", ".aiff", ".zip", ".rar", ".7z", ".tar", ".gz", ".bz2", ".xz", ".dmg", ".iso", ".pdf", ".doc", ".docx", ".ppt", ".pptx", ".xls", ".xlsx", ".exe", ".dll", ".so", ".dylib", ".bin", ".app", ".deb", ".rpm", ".db", ".sqlite", ".sqlite3", ".mdb", ".accdb", ".ttf", ".otf", ".woff", ".woff2", ".eot"]
-
Common media file extensions that should be skipped
Class Method Summary
-
.file_too_large?(file_path : String, max_size : Int32 = MAX_FILE_SIZE) : Bool
Check if a file is too large to process
-
.media_file?(file_path : String) : Bool
Check if a file should be skipped based on extension
-
.parse_size(str : String) : Int32
Parse size strings like "10MB", "500K", "1G" or raw bytes ("1048576")
-
.should_skip_file?(file_path : String, max_size : Int32 = MAX_FILE_SIZE) : Bool
Combined check - returns true if file should be skipped
-
.skip_reason(file_path : String, max_size : Int32 = MAX_FILE_SIZE) : String | Nil
Get a human-readable reason why a file was skipped
Class Method Detail
Check if a file is too large to process
Check if a file should be skipped based on extension
Parse size strings like "10MB", "500K", "1G" or raw bytes ("1048576")
Combined check - returns true if file should be skipped
Get a human-readable reason why a file was skipped