S3/Request/SetFileContents.pm

filter: Statementstmt 95.4% 21 / 22 Branchbran 62.5% 5 / 8 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 75.0% 3 / 4 Podpod 0.0% 0 / 1 totaltotal 82.8% 29 / 35 CC 5 SCAR 13.1
CC
5
Cov
87%
request
5.1
__ANON__
2.0
BEGIN
1.0
CRAP 3.7
« S3/Request/ListBucket.pm ↑ Summary S3/ResponseParser.pm »
1  
2 package AWS::S3::Request::SetFileContents;
3  
4 4 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 4 ▶use AWS::S3::ResponseParser;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 3 with 'AWS::S3::Roles::Request';
8  
9 3 has 'bucket' => (
10 is => 'ro',
11 isa => 'AWS::S3::BucketName',
12 required => 1,
13 );
14  
15 3 has 'file' => (
16 is => 'ro',
17 isa => 'AWS::S3::File',
18 required => 1,
19 );
20  
21 has 'content_type' => (
22 is => 'ro',
23 isa => 'Str',
24 required => 1,
25 lazy => 1,
26 0 ▶ default => sub { 'binary/octet-stream' },
Subroutine __ANON__: not called CC=1 SCAR=6.9
27 3 );
28  
29 3 has '+_expect_nothing' => ( default => 0 );
30  
31 20 ▶sub request {
Subroutine request: called CC=5 SCAR=16.4
Pod undocumented
32 21 my $s = shift;
33  
34 21 my $contents;
35 21 ▶ if ( ref( $s->file->contents ) eq 'CODE' ) {
Branch: 2 branches
BranchTrueFalseTotal
if (ref $s->file->contents eq 'CODE') { } 0 20 20
elsif (ref $s->file->contents eq 'SCALAR') { } 20 0 20
36 1 $contents = $s->file->contents->();
37 } elsif ( ref( $s->file->contents ) eq 'SCALAR' ) {
38 21 $contents = $s->file->contents;
39 } # end if()
40  
41 21 my %other_args = ();
42 20 ▶ $other_args{'x-amz-server-side-encryption'} = 'AES256' if $s->file->is_encrypted;
Branch: 1 branch
BranchTrueFalseTotal
if $s->file->is_encrypted 2 18 20
43  
44 # the key must be escaped, otherwise characters such as "?" or "#" in it
45 # change the meaning of the request (e.g. a key of "foo?acl" would become
46 # a PUT of the "acl" subresource rather than an upload of an object)
47 20 my $uri = $s->protocol . '://' . $s->bucket . '.' . $s->endpoint . '/' . $s->_escape_key( $s->file->key );
48  
49 20 ▶ $s->_send_request(
Branch: 1 branch
BranchTrueFalseTotal
$contents ? : 20 0 20
50 PUT => URI->new( $uri ) => {
51 Date => $s->_http_date,
52 'content-type' => $s->content_type,
53 'content-md5' => $contents ? $s->_content_md5( $$contents ) : '',
54 'x-amz-storage-class' => $s->file->storage_class,
55 },
56 $$contents
57 );
58 } # end request()
59  
60 3 __PACKAGE__->meta->make_immutable;
« S3/Request/ListBucket.pm ↑ Summary S3/ResponseParser.pm »