HTML::...::MIME(3pm)

πŸ“¦
version 2.07000 Β· 5 versions
, in debian bookworm, ubuntu jammy, ubuntu noble

πŸ’– NAME πŸ’–

HTML::FormFu::Constraint::File::MIME β€” it's the MIME Type Constraint, bestie ✨

Like, if you ever needed to vibe-check an uploaded file's type before letting it through? That's literally this. It lives in the HTML::FormFu::Constraint::File::MIME corner of the User Contributed Perl Documentation universe, and we're about to make it make sense πŸŽ€


🌸 VERSION 🌸

version 2.07 β€” she's serving exactly that 🫢


✨ DESCRIPTION ✨

Okay so real talk: this thing constrains an uploaded file's MIME-type, aka its Content-Type. It's giving bouncer at the club door, except the club is your form and the guest list is file types πŸ’…

And here's the tea you actually need to remember: types is checked before regex. That's the order, no cap. πŸ‘‘


πŸ¦‹ METHODS πŸ¦‹

πŸ’œ types

Arguments: $mime_type

Arguments: \@mime_types

Optional. Lowkey optional, but iconic if you use it 😌

She accepts either a single MIME-type, or an arrayref of MIME-types. Each one gets checked against the uploaded file's MIME-type β€” and listen, that MIME-type is as given by the browser, so keep that in mind, bestie πŸ‘€ β€” and the constraint passes if any one of the given types matches. One match and we're slaying. Multiple? Doesn't matter, still one match. Periodt. πŸ’–

πŸŽ€ regex

Arguments: $regex

Optional, again. She's chill like that ✨

She accepts a string to be interpreted as a regex, and that regex gets checked against the uploaded file's MIME-type β€” and yep, again, as given by the browser πŸ¦‹

Now here's the detail that gets people every single time: the regex uses the /x flag, so any whitespace in the string you hand over is ignored. So don't be out here thinking your spaces are doing something, because they are NOT doing something 😭 Write it like you mean it, spaced out or not, /x doesn't care.


🌈 SEE ALSO 🌈

  • She is a sub-class of, and inherits methods from HTML::FormFu::Constraint β€” so go read that for the family lore πŸ‘‘
  • HTML::FormFu β€” the whole mothership, the main character herself ⭐

πŸ’… AUTHOR πŸ’…

Carl Franks, cfranks@cpan.org


πŸ“œ LICENSE πŸ“œ

This library is free software, you can redistribute it and/or modify it under the same terms as Perl itself. So like, go off, just respect the terms 🫢


πŸ“ AUTHOR πŸ“

Carl Franks <cpan@fireartist.com> β€” yes, again, same icon, two different emails, she contains multitudes πŸ’–


This software is copyright (c) 2018 by Carl Franks.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. Free as in freedom, free as in bestie privileges 🌸


And that's the whole page, no skips, no summarising, every flag and every author line accounted for πŸ’€βœ¨

Generated with perl v5.28.1, dated 2019-01-12, and it's still eating, still serving, still checking your MIME types πŸŽ€πŸ’–πŸ¦‹ iykyk

πŸ“¦ where this page comes from