Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion s3curl.pl
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
my $copySourceRange;
my $postBody;
my $calculateContentMD5 = 0;
my $endpoint;

my $DOTFILENAME=".s3curl";
my $EXECFILE=$FindBin::Bin;
Expand Down Expand Up @@ -98,6 +99,7 @@
'help' => \$help,
'debug' => \$debug,
'calculateContentMd5' => \$calculateContentMD5,
'endpoint:s' => \$endpoint,
);

my $usage = <<USAGE;
Expand All @@ -115,6 +117,8 @@
--createBucket [<region>] create-bucket with optional location constraint
--head HEAD request
--debug enable debug logging
--endpoint [domain] add domain to list of known endpoints. If domain
is omitted, use host name extracted from URL
common curl options:
-H 'x-amz-acl: public-read' another way of using canned ACLs
-v verbose logging
Expand Down Expand Up @@ -178,7 +182,16 @@
my $arg = $ARGV[$i];
# resource name
if ($arg =~ /https?:\/\/([^\/:?]+)(?::(\d+))?([^?]*)(?:\?(\S+))?/) {
$host = $1 if !$host;
if (!$host) {
$host = $1;

# Augment the endpoints list if user supplied "--endpoint"
# parameter. If domain is specified too, use it. Otherwise,
# append currently extracted host name.
if (defined $endpoint) {
push @endpoints, length $endpoint ? $endpoint : $host;
}
}
my $port = defined $2 ? $2 : "";
my $requestURI = $3;
my $query = defined $4 ? $4 : "";
Expand Down