line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Net::Amazon::S3::Vendor; |
2
|
|
|
|
|
|
|
$Net::Amazon::S3::Vendor::VERSION = '0.98'; |
3
|
96
|
|
|
96
|
|
839
|
use Moose 0.85; |
|
96
|
|
|
|
|
2412
|
|
|
96
|
|
|
|
|
820
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
# ABSTRACT: Base class for vendor specific behaviour |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
has host => ( |
8
|
|
|
|
|
|
|
is => 'ro', |
9
|
|
|
|
|
|
|
isa => 'Str', |
10
|
|
|
|
|
|
|
required => 1, |
11
|
|
|
|
|
|
|
); |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
has authorization_method => ( |
14
|
|
|
|
|
|
|
is => 'ro', |
15
|
|
|
|
|
|
|
isa => 'Str', |
16
|
|
|
|
|
|
|
lazy => 1, |
17
|
|
|
|
|
|
|
default => sub { |
18
|
|
|
|
|
|
|
require Net::Amazon::S3::Signature::V2; |
19
|
|
|
|
|
|
|
'Net::Amazon::S3::Signature::V2', |
20
|
|
|
|
|
|
|
}, |
21
|
|
|
|
|
|
|
); |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
has use_https => ( |
24
|
|
|
|
|
|
|
is => 'ro', |
25
|
|
|
|
|
|
|
isa => 'Bool', |
26
|
|
|
|
|
|
|
lazy => 1, |
27
|
|
|
|
|
|
|
default => sub { 1 }, |
28
|
|
|
|
|
|
|
); |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
has use_virtual_host => ( |
31
|
|
|
|
|
|
|
is => 'ro', |
32
|
|
|
|
|
|
|
isa => 'Bool', |
33
|
|
|
|
|
|
|
lazy => 1, |
34
|
|
|
|
|
|
|
default => sub { $_[0]->authorization_method->enforce_use_virtual_host }, |
35
|
|
|
|
|
|
|
); |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
has default_region => ( |
38
|
|
|
|
|
|
|
is => 'ro', |
39
|
|
|
|
|
|
|
required => 0, |
40
|
|
|
|
|
|
|
default => sub { 'us-east-1' }, |
41
|
|
|
|
|
|
|
); |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
has enforce_empty_content_length => ( |
44
|
|
|
|
|
|
|
is => 'ro', |
45
|
|
|
|
|
|
|
default => sub { 1 }, |
46
|
|
|
|
|
|
|
); |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
sub guess_bucket_region { |
49
|
1
|
|
|
1
|
1
|
4
|
my ($self, $bucket) = @_; |
50
|
|
|
|
|
|
|
|
51
|
1
|
|
|
|
|
33
|
return $self->default_region; |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
1; |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
__END__ |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
=pod |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
=encoding UTF-8 |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
=head1 NAME |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
Net::Amazon::S3::Vendor - Base class for vendor specific behaviour |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
=head1 VERSION |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
version 0.98 |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
=head1 SYNOPSIS |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
# use it with Amazon AWS |
73
|
|
|
|
|
|
|
my $s3 = Net::Amazon::S3->new ( |
74
|
|
|
|
|
|
|
vendor => Net::Amazon::S3::Vendor::Amazon->new, |
75
|
|
|
|
|
|
|
..., |
76
|
|
|
|
|
|
|
); |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
# or build your own vendor description |
79
|
|
|
|
|
|
|
my $vendor = Net::Amazon::S3::Vendor::Generic->new ( |
80
|
|
|
|
|
|
|
host => 'my.s3.service', |
81
|
|
|
|
|
|
|
use_https => 1, |
82
|
|
|
|
|
|
|
use_virtual_host => 1, |
83
|
|
|
|
|
|
|
authorization_method => 'Net::Amazon::S3::Signature::V2', |
84
|
|
|
|
|
|
|
); |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
# or |
87
|
|
|
|
|
|
|
my $vendor = Net::Amazon::S3::Vendor::Generic->new ( |
88
|
|
|
|
|
|
|
host => 'my.s3.service', |
89
|
|
|
|
|
|
|
use_https => 1, |
90
|
|
|
|
|
|
|
use_virtual_host => 1, |
91
|
|
|
|
|
|
|
authorization_method => 'Net::Amazon::S3::Signature::V4', |
92
|
|
|
|
|
|
|
default_region => '...', |
93
|
|
|
|
|
|
|
); |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
# and construct your s3 connection |
96
|
|
|
|
|
|
|
my $s3 = Net::Amazon::S3->new ( |
97
|
|
|
|
|
|
|
vendor => $vendor, |
98
|
|
|
|
|
|
|
... |
99
|
|
|
|
|
|
|
); |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
=head1 DESCRIPTION |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
S3 protocol is used not only by Amazon AWS but by many other object-storage services. |
104
|
|
|
|
|
|
|
They provide same API, but it's just there's a little difference. |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
Examples? |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
Allright, you can upload file but other provider does not support multipart uploads. |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
Or although some providers support Signature V4 they may not support HEAD bucket request |
111
|
|
|
|
|
|
|
to fetch it automatically. |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
=head2 Properties |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
=head3 host |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
Required, where service is located. |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
Available here so one can move its parameters into its own vendor class. |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
=head3 authorization_method |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
Default: L<< Net::Amazon::S3::Signature::V2 >> |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
Signature class used to authorize requests. |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
=head3 use_https |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
Default: true. |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
Whether to use HTTPS or not. |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
=head3 use_virtual_host |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
Default: whatever C<authorization_method> enforces |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
Whether to use path or virtual host access style. |
138
|
|
|
|
|
|
|
Path style uses single host with bucket contained in uri path whereas virtual host style |
139
|
|
|
|
|
|
|
use bucket specific virtual hosts. |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
=head3 default_region |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
Default: undef |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
Value that C<guess_bucket_region> will return. |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
Use when your provider doesn't support HEAD region request but uses Signature V4 authorization |
148
|
|
|
|
|
|
|
method. |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
=head2 Methods |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
=head3 guess_bucket_region ($bucket) |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
Returns bucket's region |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
=head1 AUTHOR |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
Branislav Zahradník <barney@cpan.org> |
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
This software is copyright (c) 2021 by Amazon Digital Services, Leon Brocard, Brad Fitzpatrick, Pedro Figueiredo, Rusty Conover, Branislav Zahradník. |
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
165
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
=cut |