Hello,
I am a bit confused by the REST syntax - how can I PUT an arbitrary file in
the bucket? Downloading works fine (Perl+LWP), see below, but for PUT I only
see this line in the docs (http://docs.puppetlabs.com/guides/rest_api.html):
PUT /{environment}/file_bucket_file/md5/{checksum}
Should I compute the MD5 of the file and port its contents at the url ?
my code:
my $ua = LWP::UserAgent->new();
my $ay = HTTP::Headers->new; $ay->header(''Accept'' =>
''YAML'');
my $as = HTTP::Headers->new; $as->header(''Accept'' =>
''s'');
sub get_string {
my $req = HTTP::Request->new(''GET'',
"https://$server/production/file_metadata/".$_[0],
$ay);
my $res = $ua->request($req);
die "Something went wrong: ".$res->status_line unless
$res->is_success;
my @ini = YAML::Load($res->content."\n");
my $md5 = $ini[0]->{checksum}; $md5 =~ s/^{md5}//;
$req = HTTP::Request->new(''GET'',
"https://$server/production/file_bucket_file/md5/$md5",
$as);
$res = $ua->request($req);
die "Something went wrong: ".$res->status_line unless
$res->is_success;
return $res->content;
}
sub get_yaml {
my $req = HTTP::Request->new(''GET'',
"https://$server/production/file_metadata/".$_[0],
$ay);
my $res = $ua->request($req);
die "Something went wrong: ".$res->status_line unless
$res->is_success;
my @ini = YAML::Load($res->content."\n");
my $md5 = $ini[0]->{checksum}; $md5 =~ s/^{md5}//;
$req = HTTP::Request->new(''GET'',
"https://$server/production/file_bucket_file/md5/$md5",
$ay);
$res = $ua->request($req);
die "Something went wrong: ".$res->status_line unless
$res->is_success;
@ini = YAML::Load($res->content."\n");
return $ini[0];
}
--
You received this message because you are subscribed to the Google Groups
"Puppet Users" group.
To post to this group, send email to puppet-users@googlegroups.com.
To unsubscribe from this group, send email to
puppet-users+unsubscribe@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/puppet-users?hl=en.