NAME
Mojo::File - File
SYNOPSIS
use Mojo::File;
my $file = Mojo::File->new('Hello!');
$file->add_chunk('World!');
print $file->slurp;
DESCRIPTION
Mojo::File is a container for files.
ATTRIBUTES
cleanup
my $cleanup = $file->cleanup;
$file = $file->cleanup(1);
handle
my $handle = $file->handle;
$file = $file->handle(IO::File->new);
Returns a IO::File object representing a file upload if called without arguments. Returns the invocant if called with arguments.
path
my $path = $file->path;
$file = $file->path('/foo/bar.txt');
METHODS
Mojo::File inherits all methods from Mojo::Base and implements the following new ones.
new
my $file = Mojo::File->new('Hello World!');
add_chunk
$file = $file->add_chunk('test 123');
contains
my $contains = $file->contains('random string');
copy_to
$file = $file->copy_to('/foo/bar/baz.txt');
Copies the uploaded file contents to the given path and returns the invocant.
get_chunk
my $chunk = $file->get_chunk($offset);
length
my $length = $file->length;
move_to
$file = $file->move_to('/foo/bar/baz.txt');
Moves the uploaded file contents to the given path and returns the invocant.
slurp
my $string = $file->slurp;
Returns the entire file content as a string.