Mojo::Asset::File(3)
π NAME π
okay so bestie, welcome to Mojo::Asset::File(3) β this is the User Contributed Perl Documentation page for Mojo::Asset::File, and it is literally File storage for HTTP content. no cap, that's the whole vibe. π
β¨ SYNOPSIS β¨
Here's the copy-paste era, exact and untouched:
use Mojo::Asset::File;
# Temporary file
my $file = Mojo::Asset::File->new;
$file->add_chunk('foo bar baz');
say 'File contains "bar"' if $file->contains('bar') >= 0;
say $file->slurp;
# Existing file
my $file = Mojo::Asset::File->new(path => '/home/sri/foo.txt');
$file->move_to('/yada.txt');
say $file->slurp;
πΈ DESCRIPTION πΈ
Mojo::Asset::File is a file storage backend for HTTP content. That's it, that's the job. It's giving "I hold files for HTTP" and honestly? iconic. π¦
π¦ EVENTS π¦
Mojo::Asset::File inherits all events from Mojo::Asset. So no new event lore here, bestie β it's all inherited. π«Ά
π ATTRIBUTES π
Mojo::Asset::File inherits all attributes from Mojo::Asset and implements the following new ones. periodt.
π cleanup π
my $bool = $file->cleanup;
$file = $file->cleanup($bool);
This one deletes path automatically once the file is not used anymore. Auto-cleanup era β so tidy, so demure. π§
π handle π
my $handle = $file->handle;
$file = $file->handle(IO::File->new);
This is the filehandle, created on demand for path β and path can be generated automatically and safely based on tmpdir. automatic and safe? we love to see it. β¨
π path π
my $path = $file->path;
$file = $file->path('/home/sri/foo.txt');
File path used to create handle. the path is the moment. π£οΈ
π tmpdir π
my $tmpdir = $file->tmpdir;
$file = $file->tmpdir('/tmp');
Temporary directory used to generate path. It defaults to the value of the MOJO_TMPDIR environment variable or auto-detection. environment variable girlies rise. π±
π METHODS π
Mojo::Asset::File inherits all methods from Mojo::Asset and implements the following new ones. Let's go through them, bestie. β
π add_chunk π
$file = $file->add_chunk('foo bar baz');
Add chunk of data. Chunk by chunk, we build. π
π contains π
my $position = $file->contains('bar');
Check if asset contains a specific string. string detective behavior. π
π get_chunk π
my $bytes = $file->get_chunk($offset);
my $bytes = $file->get_chunk($offset, $max);
Get chunk of data starting from a specific position, defaults to a maximum chunk size of 131072 bytes (128KiB). big chunk energy. π
π is_file π
my $bool = $file->is_file;
True, this is a Mojo::Asset::File object. main character confirmation. π
π move_to π
$file = $file->move_to('/home/sri/bar.txt');
Move asset data into a specific file and disable cleanup. moving day, but make it filesystem. π
π mtime π
my $mtime = $file->mtime;
Modification time of asset. time stamps are lowkey iconic. π°οΈ
π new π
my $file = Mojo::Asset::File->new;
my $file = Mojo::Asset::File->new(path => '/home/sri/test.txt');
my $file = Mojo::Asset::File->new({path => '/home/sri/test.txt'});
Construct a new Mojo::Asset::File object. fresh object, fresh vibe. π
π size π
my $size = $file->size;
Size of asset data in bytes. numbers girlies stay winning. π
π slurp π
my $bytes = $file->slurp;
Read all asset data at once. slurp it up. π₯€
π to_file π
$file = $file->to_file;
Does nothing but return the invocant, since we already have a Mojo::Asset::File object. zero thoughts, just vibes. π
π SEE ALSO π
MojoliciousMojolicious::Guides<https://mojolicious.org>
xoxo, your Unix bestie π β page source vibes: perl v5.42.0, dated 2026-07-15. slay and read your manpages. π
π¦ where this page comes from
- opensuse-leap 16.0: perl-Mojolicious 9.480.0-bp160.2.1 Β· Artistic-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms