File Coverage

lib/Egg/Request/Upload/CGI.pm
Criterion Covered Total %
statement 12 18 66.6
branch 0 2 0.0
condition n/a
subroutine 4 10 40.0
pod 1 1 100.0
total 17 31 54.8


line stmt bran cond sub pod time code
1             package Egg::Request::Upload::CGI;
2             #
3             # Masatoshi Mizuno E<lt>lusheE<64>cpan.orgE<gt>
4             #
5             # $Id: CGI.pm 337 2008-05-14 12:30:09Z lushe $
6             #
7 1     1   472 use strict;
  1         3  
  1         39  
8 1     1   5 use warnings;
  1         4  
  1         108  
9              
10             our $VERSION = '3.01';
11              
12             sub upload {
13 0 0   0 1   Egg::Request::Upload::CGI::handler->new(@_) || (undef);
14             }
15              
16             package Egg::Request::Upload::CGI::handler;
17 1     1   6 use strict;
  1         3  
  1         40  
18 1     1   5 use base qw/ Egg::Request::Upload /;
  1         2  
  1         340  
19              
20 0     0     sub filename { $_[0]->{r}->param( $_[0]->name ) }
21 0     0     sub tempname { $_[0]->{r}->tmpFileName( $_[0]->handle ) }
22 0     0     sub size { -s $_[0]->handle }
23 0     0     sub type { $_[0]->info->{'Content-Type'} }
24 0     0     sub info { $_[0]->{r}->uploadInfo( $_[0]->handle ) }
25              
26             1;
27              
28             __END__
29              
30             =head1 NAME
31              
32             Egg::Request::Upload::CGI - File upload by CGI::Upload.
33              
34             =head1 DESCRIPTION
35              
36             L<CGI::Upload> It is a module to use the file upload function.
37              
38             This module is set up by L<Egg::Plugin::Request::Upload>.
39              
40             =head1 METHODS
41              
42             =head2 upload ([PARAM_NAME])
43              
44             The Egg::Request::Upload::CGI::handler object is returned.
45              
46             Undefined returns when the 'upload' object cannot be acquired in PARAM_NAME.
47              
48             =head1 HANDLER METHODS
49              
50             This class has succeeded to L<Egg::Request::Upload>.
51              
52             =head2 filename
53              
54             The file name of the up-loading file is returned.
55              
56             There seems to be a thing that the file name including the directory of the
57             upload environment of the client is returned though it might be the one by the
58             environment.
59              
60             When only the file name is acquired, it is good to use 'catfilename' method of
61             L<Egg::Request::Upload>.
62              
63             my $filename= $upload->filename;
64              
65             =head2 tempname
66              
67             The work passing of the up-loading file is temporarily returned.
68              
69             my $tmpfile= $upload->tempname;
70              
71             =head2 size
72              
73             The size of the upload file is returned.
74              
75             =head2 type
76              
77             The contents type of the upload file is returned.
78              
79             =head2 info
80              
81             Information on the upload file is returned.
82              
83             my $type = $upload->info->{'Content-Type'};
84              
85             =head1 SEE ALSO
86              
87             L<Egg::Release>,
88             L<Egg::Request>,
89             L<Egg::Request::Upload>,
90             L<Egg::Plugin::Request::Upload>,
91             L<CGI::Upload>,
92              
93             =head1 AUTHOR
94              
95             Masatoshi Mizuno E<lt>lusheE<64>cpan.orgE<gt>
96              
97             =head1 COPYRIGHT AND LICENSE
98              
99             Copyright (C) 2008 Bee Flag, Corp. E<lt>L<http://egg.bomcity.com/>E<gt>.
100              
101             This library is free software; you can redistribute it and/or modify
102             it under the same terms as Perl itself, either Perl version 5.8.6 or,
103             at your option, any later version of Perl 5 you may have available.
104              
105             =cut
106