1 |
dpavlin |
44 |
use strict; |
2 |
|
|
use warnings; |
3 |
|
|
|
4 |
|
|
=head1 NAME |
5 |
|
|
|
6 |
|
|
Arh::Action::UploadPicture |
7 |
|
|
|
8 |
|
|
=cut |
9 |
|
|
|
10 |
|
|
package Arh::Action::UploadPicture; |
11 |
|
|
use base qw/Arh::Action::CreatePicture/; |
12 |
|
|
|
13 |
|
|
use Data::Dump qw/dump/; |
14 |
|
|
|
15 |
|
|
=head2 take_action |
16 |
|
|
|
17 |
|
|
=cut |
18 |
|
|
|
19 |
|
|
sub take_action { |
20 |
|
|
my $self = shift; |
21 |
|
|
|
22 |
|
|
if ( my $fh = $self->argument_value('content') ) { |
23 |
|
|
|
24 |
|
|
my $filename = scalar( $fh ); |
25 |
|
|
$filename =~ s/^.*([\/\\])([^\1]+)$/$2/; |
26 |
|
|
|
27 |
|
|
local $/; |
28 |
|
|
binmode $fh; |
29 |
|
|
my $content = scalar <$fh>; |
30 |
|
|
|
31 |
|
|
warn "## $self take_action filename: $filename (", length($content), " bytes)\n"; |
32 |
|
|
|
33 |
|
|
$self->argument_value( 'filename' => $filename ); |
34 |
|
|
$self->argument_value( 'content' => $content ); |
35 |
|
|
|
36 |
|
|
} |
37 |
|
|
|
38 |
|
|
return $self->SUPER::take_action( @_ ); |
39 |
|
|
} |
40 |
|
|
|
41 |
|
|
=head2 report_success |
42 |
|
|
|
43 |
|
|
=cut |
44 |
|
|
|
45 |
|
|
sub report_success { |
46 |
|
|
my $self = shift; |
47 |
|
|
$self->result->message( 'Created ' . $self->argument_value('filename') . ' with ' . length( $self->argument_value('content') ) . ' bytes' ); |
48 |
|
|
warn "## report_success ", dump( $self->result ); |
49 |
|
|
} |
50 |
|
|
|
51 |
|
|
1; |
52 |
|
|
|