S3/Request/SetFileContents.pm

filter: Statementstmt 96.0% 24 / 25 Branchbran 50.0% 3 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 80.0% 4 / 5 Podpod 0.0% 0 / 1 totaltotal 83.7% 31 / 37 CC 4 SCAR 9.9
CC
4
Cov
87%
request
4.1
__ANON__
2.0
BEGIN
1.0
CRAP 2.7
« S3/ResponseParser.pm ↑ Summary S3/File.pm »
1  
2 package AWS::S3::Request::SetFileContents;
3  
4 2 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 2 ▶use AWS::S3::Signer;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 2 ▶use AWS::S3::ResponseParser;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 1 with 'AWS::S3::Roles::Request';
9  
10 1 has 'bucket' => (
11 is => 'ro',
12 isa => 'Str',
13 required => 1,
14 );
15  
16 1 has 'file' => (
17 is => 'ro',
18 isa => 'AWS::S3::File',
19 required => 1,
20 );
21  
22 has 'content_type' => (
23 is => 'ro',
24 isa => 'Str',
25 required => 1,
26 lazy => 1,
27 0 ▶ default => sub { 'binary/octet-stream' },
Subroutine __ANON__: not called CC=1 SCAR=6.9
28 1 );
29  
30 1 has '+_expect_nothing' => ( default => 0 );
31  
32 2 ▶sub request {
Subroutine request: called CC=4 SCAR=14.2
Pod undocumented
33 3 my $s = shift;
34  
35 3 my $contents;
36 3 ▶ if ( ref( $s->file->contents ) eq 'CODE' ) {
Branch: 2 branches
BranchTrueFalseTotal
if (ref $s->file->contents eq 'CODE') { } 0 2 2
elsif (ref $s->file->contents eq 'SCALAR') { } 2 0 2
37 1 $contents = $s->file->contents->();
38 } elsif ( ref( $s->file->contents ) eq 'SCALAR' ) {
39 3 $contents = $s->file->contents;
40 } # end if()
41  
42 3 my %other_args = ();
43 2 ▶ $other_args{'x-amz-server-side-encryption'} = 'AES256' if $s->file->is_encrypted;
Branch: 1 branch
BranchTrueFalseTotal
if $s->file->is_encrypted 2 0 2
44  
45 2 my $signer = AWS::S3::Signer->new(
46 s3 => $s->s3,
47 method => 'PUT',
48 uri => $s->protocol . '://' . $s->bucket . '.' . $s->endpoint . '/' . $s->file->key,
49 content_type => $s->content_type,
50 content => $contents,
51 headers => [ 'x-amz-storage-class', $s->file->storage_class ],
52 );
53 2 $s->_send_request(
54 $signer->method => $signer->uri => {
55 Authorization => $signer->auth_header,
56 Date => $signer->date,
57 'content-type' => $s->content_type,
58 'content-md5' => $signer->content_md5,
59 'x-amz-storage-class' => $s->file->storage_class,
60 },
61 $$contents
62 );
63 } # end request()
64  
65 1 __PACKAGE__->meta->make_immutable;
« S3/ResponseParser.pm ↑ Summary S3/File.pm »