Tools::AudioHelper
Inherits Tools::FileHelper
Constants
ALLOWED_AUDIO_FORMATS = ["wav", "mp3"]
Allowed image content types
ALLOWED_AUDIO_MAGIC_B64 = [/^UklGR.+?QVZF/, /^SUQz/]
Base64-encoded magic bytes for allowed audio formats without padding so we can do prefix checking.
MAX_AUDIO_FILE_SIZE = (32 * 1024) * 1024
UNKNOWN_AUDIO_FORMAT = "unknown"
Instance methods
allowed_audio?(base64_encoded_string : String)
Sourcedetermine_audio_format(base64_encoded_string : String) : String
Determines the content type based on the magic bytes of the image
load_audio_file_as_data(resolved_path, max_audio_file_size = MAX_AUDIO_FILE_SIZE) : String
Returns the base64-encoded data for the contents of an au; assumes path is allowed; raises errors if unable to open file or if content is not an allowed image