Created
November 3, 2022 14:30
-
-
Save cynovg/80bd301b179e329b1574f14362ee1ae9 to your computer and use it in GitHub Desktop.
work w yandex object storage
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env perl | |
use utf8; | |
use v5.30; | |
use warnings; | |
use Const::Fast; | |
use URI; | |
use URI::QueryParam; | |
use HTTP::Request::Common; | |
use LWP; | |
use AWS::Signature4; | |
const my $aws_access_key_id => ''; | |
const my $aws_secret_access_key => ''; | |
const my $scheme => 'http'; | |
const my $aws_endpoint => 'storage.yandexcloud.net'; | |
const my $aws_bucket_name => ''; | |
const my $aws_region => 'ru-central1'; | |
my $signer = AWS::Signature4->new( | |
-access_key => $aws_access_key_id, | |
-secret_key => $aws_secret_access_key, | |
); | |
my $uri = URI->new( sprintf( "%s://%s/%s", $scheme, $aws_endpoint, $aws_bucket_name ) ); | |
$uri->query_param('list-type' => 2); | |
$uri->query_param('delimeter' => '/'); | |
$uri->query_param('encoding-type' => 'url'); | |
my $request = GET($uri->as_string); | |
$signer->sign($request, $aws_region); | |
my $ua = LWP::UserAgent->new(); | |
my $response = $ua->request($request); | |
say $response->content; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment