File: Upload.pm

package info (click to toggle)
libmojolicious-perl 0.999926-1%2Bsqueeze2
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 1,672 kB
  • ctags: 949
  • sloc: perl: 17,391; makefile: 4
file content (106 lines) | stat: -rw-r--r-- 1,901 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
# Copyright (C) 2008-2010, Sebastian Riedel.

package Mojo::Upload;

use strict;
use warnings;

use base 'Mojo::Base';

use Carp 'croak';
use Mojo::Asset::File;
use Mojo::Headers;

__PACKAGE__->attr(asset => sub { Mojo::Asset::File->new });
__PACKAGE__->attr([qw/filename name/]);
__PACKAGE__->attr(headers => sub { Mojo::Headers->new });

# B-6
# You sunk my scrabbleship!
# This game makes no sense.
# Tell that to the good men who just lost their lives... SEMPER-FI!
sub move_to { shift->asset->move_to(@_) }

sub size { shift->asset->size }

sub slurp { shift->asset->slurp }

1;
__END__

=head1 NAME

Mojo::Upload - Upload Container

=head1 SYNOPSIS

    use Mojo::Upload;

    my $upload = Mojo::Upload->new;
    print $upload->filename;
    $upload->move_to('/foo/bar/baz.txt');

=head1 DESCRIPTION

L<Mojo::Upload> is a container for uploads.

=head1 ATTRIBUTES

L<Mojo::Upload> implements the following attributes.

=head2 C<asset>

    my $asset = $upload->asset;
    $upload   = $upload->asset(Mojo::Asset::File->new);

Asset containing the uploaded data.

=head2 C<filename>

    my $filename = $upload->filename;
    $upload      = $upload->filename('foo.txt');

Name of the uploaded file.

=head2 C<headers>

    my $headers = $upload->headers;
    $upload     = $upload->headers(Mojo::Headers->new);

Headers for upload.

=head2 C<name>

    my $name = $upload->name;
    $upload  = $upload->name('foo');

Name of the upload.

=head1 METHODS

L<Mojo::Upload> inherits all methods from L<Mojo::Base> and implements the
following new ones.

=head2 C<move_to>

    $upload->move_to('/foo/bar/baz.txt');

Move uploaded data to a specific file.

=head2 C<size>

    my $size = $upload->size;

Size of upload in bytes.

=head2 C<slurp>

    my $string = $upload->slurp;

Read all upload data at once.

=head1 SEE ALSO

L<Mojolicious>, L<Mojolicious::Guides>, L<http://mojolicious.org>.

=cut