line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
|
2
|
|
|
|
|
|
|
package AWS::S3::Request::SetFileContents; |
3
|
|
|
|
|
|
|
|
4
|
1
|
|
|
1
|
|
881
|
use Moose; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
5
|
|
5
|
1
|
|
|
1
|
|
4252
|
use AWS::S3::Signer; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
36
|
|
6
|
1
|
|
|
1
|
|
96
|
use AWS::S3::ResponseParser; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
with 'AWS::S3::Roles::Request'; |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
has 'bucket' => ( |
11
|
|
|
|
|
|
|
is => 'ro', |
12
|
|
|
|
|
|
|
isa => 'Str', |
13
|
|
|
|
|
|
|
required => 1, |
14
|
|
|
|
|
|
|
); |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
default => sub { 'binary/octet-stream' }, |
28
|
|
|
|
|
|
|
); |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
has '+_expect_nothing' => ( default => 0 ); |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub request { |
33
|
|
|
|
|
|
|
my $s = shift; |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
my $contents; |
36
|
|
|
|
|
|
|
if ( ref( $s->file->contents ) eq 'CODE' ) { |
37
|
|
|
|
|
|
|
$contents = $s->file->contents->(); |
38
|
|
|
|
|
|
|
} elsif ( ref( $s->file->contents ) eq 'SCALAR' ) { |
39
|
|
|
|
|
|
|
$contents = $s->file->contents; |
40
|
|
|
|
|
|
|
} # end if() |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
my %other_args = (); |
43
|
|
|
|
|
|
|
$other_args{'x-amz-server-side-encryption'} = 'AES256' if $s->file->is_encrypted; |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
$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
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |