File Coverage

blib/lib/Mojo/Upload.pm
Criterion Covered Total %
statement 6 6 100.0
branch 1 2 50.0
condition n/a
subroutine 4 4 100.0
pod 3 3 100.0
total 14 15 93.3


line stmt bran cond sub pod time code
1             package Mojo::Upload;
2 60     60   68704 use Mojo::Base -base;
  60         174  
  60         550  
3              
4             has [qw(asset filename headers name)];
5              
6 1 50   1 1 6 sub move_to { $_[0]->asset->move_to($_[1]) and return $_[0] }
7              
8 7     7 1 33 sub size { shift->asset->size }
9 9     9 1 54 sub slurp { shift->asset->slurp }
10              
11             1;
12              
13             =encoding utf8
14              
15             =head1 NAME
16              
17             Mojo::Upload - Upload
18              
19             =head1 SYNOPSIS
20              
21             use Mojo::Upload;
22              
23             my $upload = Mojo::Upload->new;
24             say $upload->filename;
25             $upload->move_to('/home/sri/foo.txt');
26              
27             =head1 DESCRIPTION
28              
29             L is a container for uploaded files.
30              
31             =head1 ATTRIBUTES
32              
33             L implements the following attributes.
34              
35             =head2 asset
36              
37             my $asset = $upload->asset;
38             $upload = $upload->asset(Mojo::Asset::File->new);
39              
40             Asset containing the uploaded data, usually a L or L object.
41              
42             =head2 filename
43              
44             my $filename = $upload->filename;
45             $upload = $upload->filename('foo.txt');
46              
47             Name of the uploaded file.
48              
49             =head2 headers
50              
51             my $headers = $upload->headers;
52             $upload = $upload->headers(Mojo::Headers->new);
53              
54             Headers for upload, usually a L object.
55              
56             =head2 name
57              
58             my $name = $upload->name;
59             $upload = $upload->name('foo');
60              
61             Name of the upload.
62              
63             =head1 METHODS
64              
65             L inherits all methods from L and implements the following new ones.
66              
67             =head2 move_to
68              
69             $upload = $upload->move_to('/home/sri/foo.txt');
70              
71             Move uploaded data into a specific file.
72              
73             =head2 size
74              
75             my $size = $upload->size;
76              
77             Size of uploaded data in bytes.
78              
79             =head2 slurp
80              
81             my $bytes = $upload->slurp;
82              
83             Read all uploaded data at once.
84              
85             =head1 SEE ALSO
86              
87             L, L, L.
88              
89             =cut