| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package HTML::FormFu::UploadParam; |
|
2
|
|
|
|
|
|
|
|
|
3
|
9
|
|
|
9
|
|
51
|
use strict; |
|
|
9
|
|
|
|
|
12
|
|
|
|
9
|
|
|
|
|
381
|
|
|
4
|
|
|
|
|
|
|
our $VERSION = '2.05'; # VERSION |
|
5
|
|
|
|
|
|
|
|
|
6
|
9
|
|
|
9
|
|
43
|
use Moose; |
|
|
9
|
|
|
|
|
12
|
|
|
|
9
|
|
|
|
|
41
|
|
|
7
|
9
|
|
|
9
|
|
36063
|
use MooseX::Attribute::FormFuChained; |
|
|
9
|
|
|
|
|
17
|
|
|
|
9
|
|
|
|
|
703
|
|
|
8
|
|
|
|
|
|
|
|
|
9
|
9
|
|
|
9
|
|
42
|
use Carp qw( croak ); |
|
|
9
|
|
|
|
|
13
|
|
|
|
9
|
|
|
|
|
460
|
|
|
10
|
|
|
|
|
|
|
|
|
11
|
9
|
|
|
9
|
|
724
|
use File::Temp qw( tempfile ); |
|
|
9
|
|
|
|
|
6307
|
|
|
|
9
|
|
|
|
|
501
|
|
|
12
|
9
|
|
|
9
|
|
35
|
use Scalar::Util qw( weaken ); |
|
|
9
|
|
|
|
|
13
|
|
|
|
9
|
|
|
|
|
320
|
|
|
13
|
9
|
|
|
9
|
|
318
|
use Storable qw( nfreeze thaw ); |
|
|
9
|
|
|
|
|
12
|
|
|
|
9
|
|
|
|
|
3307
|
|
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
has param => ( is => 'rw', traits => ['FormFuChained'], required => 1 ); |
|
16
|
|
|
|
|
|
|
has filename => ( is => 'rw', traits => ['FormFuChained'] ); |
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub form { |
|
19
|
24
|
|
|
24
|
0
|
29
|
my $self = shift; |
|
20
|
|
|
|
|
|
|
|
|
21
|
24
|
50
|
|
|
|
42
|
if (@_) { |
|
22
|
24
|
|
|
|
|
30
|
$self->{form} = shift; |
|
23
|
|
|
|
|
|
|
|
|
24
|
24
|
|
|
|
|
50
|
weaken( $self->{form} ); |
|
25
|
|
|
|
|
|
|
} |
|
26
|
|
|
|
|
|
|
|
|
27
|
24
|
|
|
|
|
31
|
return $self->{form}; |
|
28
|
|
|
|
|
|
|
} |
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
sub STORABLE_freeze { |
|
31
|
0
|
|
|
0
|
0
|
|
my ( $self, $cloning ) = @_; |
|
32
|
|
|
|
|
|
|
|
|
33
|
0
|
0
|
|
|
|
|
return if $cloning; |
|
34
|
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
my $fh |
|
36
|
|
|
|
|
|
|
= $self->{param}->can('fh') |
|
37
|
|
|
|
|
|
|
? $self->{param}->fh |
|
38
|
0
|
0
|
|
|
|
|
: $self->{param}; |
|
39
|
|
|
|
|
|
|
|
|
40
|
0
|
|
|
|
|
|
seek $fh, 0, 0; |
|
41
|
|
|
|
|
|
|
|
|
42
|
0
|
|
|
|
|
|
local $/ = undef; |
|
43
|
0
|
|
|
|
|
|
my $data = <$fh>; |
|
44
|
|
|
|
|
|
|
|
|
45
|
0
|
0
|
|
|
|
|
if ( defined( my $dir = $self->form->tmp_upload_dir ) ) { |
|
46
|
0
|
|
|
|
|
|
my ( $fh, $filename ) = tempfile( DIR => $dir, UNLINK => 0 ); |
|
47
|
|
|
|
|
|
|
|
|
48
|
0
|
|
|
|
|
|
print $fh $data; |
|
49
|
|
|
|
|
|
|
|
|
50
|
0
|
|
|
|
|
|
close $fh; |
|
51
|
|
|
|
|
|
|
|
|
52
|
0
|
|
|
|
|
|
return nfreeze( { filename => $filename } ); |
|
53
|
|
|
|
|
|
|
} |
|
54
|
|
|
|
|
|
|
else { |
|
55
|
0
|
|
|
|
|
|
return nfreeze( { param => $data } ); |
|
56
|
|
|
|
|
|
|
} |
|
57
|
|
|
|
|
|
|
} |
|
58
|
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
sub STORABLE_thaw { |
|
60
|
0
|
|
|
0
|
0
|
|
my ( $self, $cloning, $serialized ) = @_; |
|
61
|
|
|
|
|
|
|
|
|
62
|
0
|
0
|
|
|
|
|
return if $cloning; |
|
63
|
|
|
|
|
|
|
|
|
64
|
0
|
|
|
|
|
|
my $data = thaw($serialized); |
|
65
|
|
|
|
|
|
|
|
|
66
|
0
|
|
|
|
|
|
my $filename = $data->{filename}; |
|
67
|
|
|
|
|
|
|
|
|
68
|
0
|
0
|
|
|
|
|
if ($filename) { |
|
69
|
0
|
0
|
|
|
|
|
open my $fh, '<', $filename |
|
70
|
|
|
|
|
|
|
or croak "could not open file in tmp dir: '$filename'"; |
|
71
|
|
|
|
|
|
|
|
|
72
|
0
|
|
|
|
|
|
$self->{param} = $fh; |
|
73
|
0
|
|
|
|
|
|
$self->{filename} = $filename; |
|
74
|
|
|
|
|
|
|
} |
|
75
|
|
|
|
|
|
|
else { |
|
76
|
0
|
|
|
|
|
|
my ($fh) = tempfile(); |
|
77
|
|
|
|
|
|
|
|
|
78
|
0
|
|
|
|
|
|
print $fh $data->{param}; |
|
79
|
|
|
|
|
|
|
|
|
80
|
0
|
|
|
|
|
|
seek $fh, 0, 0; |
|
81
|
|
|
|
|
|
|
|
|
82
|
0
|
|
|
|
|
|
$self->{param} = $fh; |
|
83
|
|
|
|
|
|
|
} |
|
84
|
|
|
|
|
|
|
|
|
85
|
0
|
|
|
|
|
|
return; |
|
86
|
|
|
|
|
|
|
} |
|
87
|
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
|
89
|
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
1; |
|
91
|
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
__END__ |
|
93
|
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=head1 NAME |
|
95
|
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
HTML::FormFu::UploadParam - accessor class |
|
97
|
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
=head1 VERSION |
|
99
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
version 2.05 |
|
101
|
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
103
|
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
=head1 SEE ALSO |
|
105
|
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
L<HTML::FormFu>, L<HTML::FormFu::Upload> |
|
107
|
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
=head1 AUTHOR |
|
109
|
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
Carl Franks, C<cfranks@cpan.org> |
|
111
|
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
=head1 LICENSE |
|
113
|
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
This library is free software, you can redistribute it and/or modify it under |
|
115
|
|
|
|
|
|
|
the same terms as Perl itself. |
|
116
|
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
=cut |