line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# Copyright 2019, Google LLC |
2
|
|
|
|
|
|
|
# |
3
|
|
|
|
|
|
|
# Licensed under the Apache License, Version 2.0 (the "License"); |
4
|
|
|
|
|
|
|
# you may not use this file except in compliance with the License. |
5
|
|
|
|
|
|
|
# You may obtain a copy of the License at |
6
|
|
|
|
|
|
|
# |
7
|
|
|
|
|
|
|
# http://www.apache.org/licenses/LICENSE-2.0 |
8
|
|
|
|
|
|
|
# |
9
|
|
|
|
|
|
|
# Unless required by applicable law or agreed to in writing, software |
10
|
|
|
|
|
|
|
# distributed under the License is distributed on an "AS IS" BASIS, |
11
|
|
|
|
|
|
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
12
|
|
|
|
|
|
|
# See the License for the specific language governing permissions and |
13
|
|
|
|
|
|
|
# limitations under the License. |
14
|
|
|
|
|
|
|
# |
15
|
|
|
|
|
|
|
# This module contains utility methods for media processing. |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
use strict; |
19
|
2
|
|
|
2
|
|
1567
|
use warnings; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
46
|
|
20
|
2
|
|
|
2
|
|
9
|
use version; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
50
|
|
21
|
2
|
|
|
2
|
|
335
|
|
|
2
|
|
|
|
|
1366
|
|
|
2
|
|
|
|
|
9
|
|
22
|
|
|
|
|
|
|
# The following needs to be on one line because CPAN uses a particularly hacky |
23
|
|
|
|
|
|
|
# eval() to determine module versions. |
24
|
|
|
|
|
|
|
use Google::Ads::GoogleAds::Constants; our $VERSION = ${Google::Ads::GoogleAds::Constants::VERSION}; |
25
|
2
|
|
|
2
|
|
432
|
|
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
76
|
|
26
|
|
|
|
|
|
|
use Exporter 'import'; |
27
|
2
|
|
|
2
|
|
11
|
our @EXPORT = qw(get_base64_data_from_url); |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
92
|
|
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
use HTTP::Request; |
30
|
2
|
|
|
2
|
|
410
|
use LWP::UserAgent; |
|
2
|
|
|
|
|
15752
|
|
|
2
|
|
|
|
|
66
|
|
31
|
2
|
|
|
2
|
|
579
|
use URI::Escape; |
|
2
|
|
|
|
|
24213
|
|
|
2
|
|
|
|
|
65
|
|
32
|
2
|
|
|
2
|
|
11
|
use MIME::Base64; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
105
|
|
33
|
2
|
|
|
2
|
|
392
|
|
|
2
|
|
|
|
|
579
|
|
|
2
|
|
|
|
|
234
|
|
34
|
|
|
|
|
|
|
# Gets the image data (byte representation) from a given URL. |
35
|
|
|
|
|
|
|
my $url = shift; |
36
|
|
|
|
|
|
|
my $request = HTTP::Request->new(GET => $url); |
37
|
2
|
|
|
2
|
1
|
807
|
my $response = LWP::UserAgent->new->request($request); |
38
|
2
|
|
|
|
|
10
|
return encode_base64($response->content, '') if $response->is_success; |
39
|
2
|
|
|
|
|
6541
|
} |
40
|
2
|
50
|
|
|
|
1642968
|
|
41
|
|
|
|
|
|
|
1; |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
=pod |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
=head1 NAME |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
Google::Ads::GoogleAds::Utils::MediaUtils |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
=head1 SYNOPSIS |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
use Google::Ads::GoogleAds::Utils::MediaUtils; |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
my $image_data = get_base64_data_from_url("https://gaagl.page.link/Eit5"); |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
if ($image_data) { |
56
|
|
|
|
|
|
|
# Make use of $image_data. |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
=head1 DESCRIPTION |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
This module contains utility methods for media processing. |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=head1 METHODS |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=head2 get_base64_data_from_url |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
Gets the image data (byte representation) from a given URL. |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
=head3 Parameters |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
The URL from which the data will be retrieved. |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=head3 Returns |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
A base64 encoded string of the image data. Or undef if the image is not found. |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=head1 LICENSE AND COPYRIGHT |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
Copyright 2019 Google LLC |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
Licensed under the Apache License, Version 2.0 (the "License"); |
82
|
|
|
|
|
|
|
you may not use this file except in compliance with the License. |
83
|
|
|
|
|
|
|
You may obtain a copy of the License at |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0 |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
Unless required by applicable law or agreed to in writing, software |
88
|
|
|
|
|
|
|
distributed under the License is distributed on an "AS IS" BASIS, |
89
|
|
|
|
|
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
90
|
|
|
|
|
|
|
See the License for the specific language governing permissions and |
91
|
|
|
|
|
|
|
limitations under the License. |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
=head1 REPOSITORY INFORMATION |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
$Rev: $ |
96
|
|
|
|
|
|
|
$LastChangedBy: $ |
97
|
|
|
|
|
|
|
$Id: $ |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
=cut |