1 | package Mojo::Upload;
|
---|
2 | use Mojo::Base -base;
|
---|
3 |
|
---|
4 | has [qw(asset filename headers name)];
|
---|
5 |
|
---|
6 | sub move_to { $_[0]->asset->move_to($_[1]) and return $_[0] }
|
---|
7 |
|
---|
8 | sub size { shift->asset->size }
|
---|
9 | 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<Mojo::Upload> is a container for uploaded files.
|
---|
30 |
|
---|
31 | =head1 ATTRIBUTES
|
---|
32 |
|
---|
33 | L<Mojo::Upload> 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<Mojo::Asset::File> or
|
---|
41 | L<Mojo::Asset::Memory> object.
|
---|
42 |
|
---|
43 | =head2 filename
|
---|
44 |
|
---|
45 | my $filename = $upload->filename;
|
---|
46 | $upload = $upload->filename('foo.txt');
|
---|
47 |
|
---|
48 | Name of the uploaded file.
|
---|
49 |
|
---|
50 | =head2 headers
|
---|
51 |
|
---|
52 | my $headers = $upload->headers;
|
---|
53 | $upload = $upload->headers(Mojo::Headers->new);
|
---|
54 |
|
---|
55 | Headers for upload, usually a L<Mojo::Headers> object.
|
---|
56 |
|
---|
57 | =head2 name
|
---|
58 |
|
---|
59 | my $name = $upload->name;
|
---|
60 | $upload = $upload->name('foo');
|
---|
61 |
|
---|
62 | Name of the upload.
|
---|
63 |
|
---|
64 | =head1 METHODS
|
---|
65 |
|
---|
66 | L<Mojo::Upload> inherits all methods from L<Mojo::Base> and implements the
|
---|
67 | following new ones.
|
---|
68 |
|
---|
69 | =head2 move_to
|
---|
70 |
|
---|
71 | $upload = $upload->move_to('/home/sri/foo.txt');
|
---|
72 |
|
---|
73 | Move uploaded data into a specific file.
|
---|
74 |
|
---|
75 | =head2 size
|
---|
76 |
|
---|
77 | my $size = $upload->size;
|
---|
78 |
|
---|
79 | Size of uploaded data in bytes.
|
---|
80 |
|
---|
81 | =head2 slurp
|
---|
82 |
|
---|
83 | my $bytes = $upload->slurp;
|
---|
84 |
|
---|
85 | Read all uploaded data at once.
|
---|
86 |
|
---|
87 | =head1 SEE ALSO
|
---|
88 |
|
---|
89 | L<Mojolicious>, L<Mojolicious::Guides>, L<https://mojolicious.org>.
|
---|
90 |
|
---|
91 | =cut
|
---|