NAME

Protocol::Tus::Upload

SYNOPSIS

# most probable way to get such an object
my $model = ...; # something adhering to Protocol::Tus::AbstractModel
my $item = $model->upload_for($id);

# strictly speaking...
use Protocol::Tus::Upload;
my $upload = Protocol::Tus::Upload->new(model => $model, id => $id);

DESCRIPTION

Handler class wrapping methods of Protocol::Tus::AbstractModel based on a specific upload.

Instead of this:

my $info = $model->get_info($id);
$model->set_length($id, $some_length);
$model->save_chunk($id, $offset, $data_reference);
my $offset = $model->get_offset($id);

you can use a more natural interface like this:

my $upload = $model->upload_for($id);
my $info = $upload->get_info;
$upload->set_length($some_length);
$upload->save_chunk($offset, $data_reference);
my $offset = $upload->get_offset;

INTERFACE

All methods are wrappers around the corresponding method with the same name in the model class (whose interface must be compatible with Protocol::Tus::AbstractModel).

cleanup

$upload->cleanup;

See "cleanup" in Protocol::Tus::AbstractModel.

finalize

$upload->finalize;

See "finalize" in Protocol::Tus::AbstractModel.

get_info

my $hash_ref = $upload->get_info;

See "get_info" in Protocol::Tus::AbstractModel.

get_offset

my $offset = $upload->get_offset;

See "get_offset" in Protocol::Tus::AbstractModel.

is_complete

my $bool = $upload->is_complete;

See "is_complete" in Protocol::Tus::AbstractModel.

id

my $id = $upload->id;

Accessor to the identifier of the upload.

new

my $upload = Protocol::Tus::Upload->new(model => $model, id => $id);

Constructor. Accepts two mandatory named parameters: the model (compatible with Protocol::Tus::AbstractModel) and the upload identifier (according to the model's restrictions).

model

my $model = $upload->model;

Accessor to the model that manages the upload.

save_chunk

$upload->save_chunk($offset, $data_ref);

See "save_chunk" in Protocol::Tus::AbstractModel.

set_length

$upload->set_length($length);

See "set_length" in Protocol::Tus::AbstractModel.

ANYTHING ELSE (INCLUDING AUTHOR, COPYRIGHT AND LICENSE)

See documentation for Protocol::Tus.