RWDE/DB/BigFile.pm untested

filter: Statementstmt 0.0% 0 / 68 Branchbran n/a Conditioncond 0.0% 0 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 0.0% 0 / 16 Podpod 0.0% 0 / 8 totaltotal 0.0% 0 / 95 CC 1 SCAR 6.9
CC
1
Cov
0%
s3_put
2.0
s3_delete
2.0
s3_get
2.0
CRAP 2.0
1 package RWDE::DB::BigFile;
2  
3 use strict;
4 use warnings;
5  
6 use Error qw(:try);
7  
8 use RWDE::Configuration;
9 use RWDE::Exceptions;
10 use RWDE::DB::S3;
11  
12  
13 use vars qw($VERSION);
14 $VERSION = sprintf "%d", q$Revision: 554 $ =~ /(\d+)/;
15  
16 sub s3_put {
17 my ($self, $params) = @_;
18  
19 my %S3_hash = $self->get_s3_hash();
20  
21 while ( my ($field, $key) = each(%S3_hash) ) {
22 $self->Put({ key_name => $key, content_type => $self->image_filetype, content => $self->$field });
23 }
24
25 return();
26 }
27  
28 sub s3_delete {
29 my ($self, $params) = @_;
30  
31 my %S3_hash = $self->get_s3_hash();
32  
33 while ( my ($field, $key) = each(%S3_hash) ) {
34 $self->Delete({ key_name => $key }); }
35  
36 return();
37 }
38  
39 sub s3_get {
40 my ($self, $params) = @_;
41  
42 my %S3_hash = $self->get_s3_hash();
43 my $field = $$params{field_name} || 'image_data';
44 return $self->Get({ key_name => $S3_hash{$field} });
45 }
46  
47 sub s3_publicRead {
48 my ($self, $params) = @_;
49 my %S3_hash = $self->get_s3_hash();
50  
51 while ( my ($field, $key) = each(%S3_hash) ) {
52 $self->Put({ key_name => $key, content_type => $self->image_filetype, content => $self->get_data(), acl => 'public-read' });
53 }
54 }
55  
56 sub s3_noPublicRead {
57 my ($self, $params) = @_;
58 my %S3_hash = $self->get_s3_hash();
59  
60 while ( my ($field, $key) = each(%S3_hash) ) {
61 $self->Put({ key_name => $key, content_type => $self->image_filetype, content => $self->get_data(), acl => 'private' });
62 }
63 }
64  
65 sub Put {
66 my ($self, $params) = @_;
67  
68 my $s3 = RWDE::DB::S3->new();
69  
70 use CGI;
71 $s3->putObject(RWDE::Configuration->S3BucketName, CGI::escape($$params{key_name}), $$params{content_type}, $$params{content},
72 $$params{acl});
73
74 return();
75 }
76  
77 sub Delete {
78 my ($self, $params) = @_;
79  
80 my $s3 = RWDE::DB::S3->new();
81  
82 $s3->deleteObject(RWDE::Configuration->S3BucketName, $$params{key_name});
83  
84 return();
85 }
86  
87 sub Get {
88 my ($self, $params) = @_;
89  
90 my $s3 = RWDE::DB::S3->new();
91  
92 my $response = $s3->getObject(RWDE::Configuration->S3BucketName, $$params{key_name});
93
94 return $response->content;
95 }
96  
97  
98 1;
99