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