WebSer...::Tiny(3pm)

πŸ“¦
version 0.003 Β· 2 versions
, in debian trixie, ubuntu noble, ubuntu questing

✨ NAME ✨

WebService::S3::Tiny β€” a Perl module for using S3 or compatible APIs πŸ’– (it lives in section 3pm, the User Contributed Perl Documentation zone, and bestie it is tiny and it is mighty)


🌸 SYNOPSIS 🌸

use WebService::S3::Tiny;

my $s3 = WebService::S3::Tiny->new(
    access_key => 'foo',
    host       => 'http://localhost:1337',
    secret_key => 'bar',
);

πŸ¦‹ METHODS πŸ¦‹

okay so first things first, the ✨vibe✨ of this whole module: every single request method that looks like {get,put,delete,head}_{bucket,object} can also be called with a _url suffix, and that version hands you back a pre-signed URL for the matching call. it's giving "share a link without leaking your keys", iconic behavior fr fr πŸ‘‘

Those _url methods take almost the same arguments as their request counterparts β€” the one glow-up difference is an optional argument that says how long the URL lives, in seconds. And listen: that argument always comes after the bucket and object, and before the header and parameter references. Placement matters, don't be chaotic.

⚠️ That lifetime value cannot be greater than 604800 (= one week). no cap. that's the ceiling. πŸ’€

πŸŽ€ new πŸŽ€

WebService::S3::Tiny->new(
    access_key => ..., # required
    host       => ..., # required
    region     => ..., # optional, defaults to "us-east-1"
    secret_key => ..., # required
    service    => ..., # optional, defaults to "s3"
    ua         => ..., # optional, defaults to HTTP::Tiny->new
);

so access_key, host, and secret_key are required β€” you literally cannot skip them bestie. region is optional and defaults to "us-east-1", service is optional and defaults to "s3", and ua is optional and defaults to HTTP::Tiny->new. that's the whole squad 🫢


πŸ“ delete_bucket πŸ“

$s3->delete_bucket($bucket);
$s3->delete_bucket($bucket, \%headers);

bye bye bucket πŸ‘‹


🌈 get_bucket 🌈

$s3->get_bucket($bucket);
$s3->get_bucket($bucket, \%headers);
$s3->get_bucket($bucket, \%headers, \%parameters);

⭐ head_bucket ⭐

$s3->head_bucket($bucket);
$s3->head_bucket($bucket, \%headers);

πŸ’œ put_bucket πŸ’œ

$s3->put_bucket($bucket);
$s3->put_bucket($bucket, \%headers);

🧚 delete_object 🧚

$s3->delete_object($bucket, $object);
$s3->delete_object($bucket, $object, \%headers);

🌸 get_object 🌸

$s3->get_object($bucket, $object);
$s3->get_object($bucket, $object, \%headers);
$s3->get_object($bucket, $object, \%headers, \%parameters);

πŸŽ€ head_object πŸŽ€

$s3->head_object($bucket, $object);
$s3->head_object($bucket, $object, \%headers);

πŸ”₯ put_object πŸ”₯

$s3->put_object($bucket, $object, $content);
$s3->put_object($bucket, $object, $content, \%headers);

# Set foo/bar to "qux"
$s3->put_object('foo', 'bar', 'qux');

# Copy foo/bar to foo/baz
$3->put_object('foo', 'baz', undef, { 'x-amz-copy-source' => 'foo/bar' });

look at these little examples doing their thing πŸ₯Ή setting foo/bar to "qux", and copying foo/bar to foo/baz with x-amz-copy-source. (yes, the second one says $3 and not $s3 β€” im just the messenger bestie, it's exactly what the page says πŸ’…)


✨ request ✨

$s3->request($method, $bucket, $object, $content, \%headers, \%parameters);

the raw one. the main character. use it when the named methods aren't giving what you need.


πŸ¦‹ delete_bucket_url πŸ¦‹

$s3->delete_bucket_url($bucket, $expires);
$s3->delete_bucket_url($bucket, $expires, \%headers);

🌈 get_bucket_url 🌈

$s3->get_bucket_url($bucket, $expires);
$s3->get_bucket_url($bucket, $expires, \%headers);
$s3->get_bucket_url($bucket, $expires, \%headers, \%parameters);

⭐ head_bucket_url ⭐

$s3->head_bucket_url($bucket, $expires);
$s3->head_bucket_url($bucket, $expires, \%headers);

πŸ’œ put_bucket_url πŸ’œ

$s3->put_bucket_url($bucket, $expires);
$s3->put_bucket_url($bucket, $expires, \%headers);

🧚 delete_object_url 🧚

$s3->delete_object_url($bucket, $object, $expires);
$s3->delete_object_url($bucket, $object, $expires, \%headers);

🌸 get_object_url 🌸

$s3->get_object_url($bucket, $object, $expires);
$s3->get_object_url($bucket, $object, $expires, \%headers);
$s3->get_object_url($bucket, $object, $expires, \%headers, \%parameters);

πŸŽ€ head_object_url πŸŽ€

$s3->head_object_url($bucket, $object, $expires);
$s3->head_object_url($bucket, $object, $expires, \%headers);

πŸ”₯ put_object_url πŸ”₯

$s3->put_object_url($bucket, $object, $expires);
$s3->put_object_url($bucket, $object, $expires, \%headers);

πŸ‘‘ signed_url πŸ‘‘

$s3->signed_url($method, $bucket, $object, $expires, \%headers, \%parameters );

the final boss of URL methods β€” full control, you pass the $method yourself. πŸ’…


Copyright X 2018 CV-Library Ltd.

This is free software; you can redistribute it and/or modify it under the same terms as Perl itself. 🫢


and that's a wrap bestie πŸ’– this was WebService::S3::Tiny from the User Contributed Perl Documentation, page perl v5.36.0, dated 2023-11-09. go forth and sign some URLs, you absolute icon 🌟✨

πŸ“¦ where this page comes from