<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">NAME
    `Net::Async::Webservice::S3' - use Amazon's S3 web service with
    `IO::Async'

SYNOPSIS
     use IO::Async::Loop;
     use Net::Async::Webservice::S3;

     my $loop = IO::Async::Loop-&gt;new;

     my $s3 = Net::Async::Webservice::S3-&gt;new(
        access_key =&gt; ...,
        secret_key =&gt; ...,
        bucket     =&gt; "my-bucket-here",
     );
     $loop-&gt;add( $s3 );

     my $put_f = $s3-&gt;put_object(
        key   =&gt; "the-key",
        value =&gt; "A new value for the key\n";
     );

     my $get_f = $s3-&gt;get_object(
        key =&gt; "another-key",
     );

     $loop-&gt;await_all( $put_f, $get_f );

     print "The value is:\n", $get_f-&gt;get;

DESCRIPTION
    This module provides a webservice API around Amazon's S3 web service for
    use in an IO::Async-based program. Each S3 operation is represented by a
    method that returns a Future; this future, if successful, will
    eventually return the result of the operation.

PARAMETERS
    The following named parameters may be passed to `new' or `configure':

    http =&gt; Net::Async::HTTP
            Optional. Allows the caller to provide a specific asynchronous
            HTTP user agent object to use. This will be invoked with a
            single method, as documented by Net::Async::HTTP:

             $response_f = $http-&gt;do_request( request =&gt; $request, ... )

            If absent, a new instance will be created and added as a child
            notifier of this object. If a value is supplied, it will be used
            as supplied and *not* specifically added as a child notifier. In
            this case, the caller must ensure it gets added to the
            underlying IO::Async::Loop instance, if required.

    access_key =&gt; STRING
    secret_key =&gt; STRING
            The twenty-character Access Key ID and forty-character Secret
            Key to use for authenticating requests to S3.

    ssl =&gt; BOOL
            Optional. If given a true value, will use `https' URLs over SSL.
            Defaults to off. This feature requires the optional
            IO::Async::SSL module if using Net::Async::HTTP.

    bucket =&gt; STRING
            Optional. If supplied, gives the default bucket name to use, at
            which point it is optional to supply to the remaining methods.

    prefix =&gt; STRING
            Optional. If supplied, this prefix string is prepended to any
            key names passed in methods, and stripped from the response from
            `list_bucket'. It can be used to keep operations of the object
            contained within the named key space. If this string is
            supplied, don't forget that it should end with the path
            delimiter in use by the key naming scheme (for example `/').

    max_retries =&gt; INT
            Optional. Maximum number of times to retry a failed operation.
            Defaults to 3.

    list_max_keys =&gt; INT
            Optional. Maximum number of keys at a time to request from S3
            for the `list_bucket' method. Larger values may be more
            efficient as fewer roundtrips will be required per method call.
            Defaults to 1000.

    part_size =&gt; INT
            Optional. Size in bytes to break content for using multipart
            upload. If an object key's size is no larger than this value,
            multipart upload will not be used. Defaults to 100 MiB.

    read_size =&gt; INT
            Optional. Size in bytes to read per call to the `$gen_value'
            content generation function in `put_object'. Defaults to 64 KiB.

    timeout =&gt; NUM
    stall_timeout =&gt; NUM
            Optional. If configured, these are passed into the underlying
            `Net::Async::HTTP' object.

METHODS
    The following methods all support the following common arguments:

    timeout =&gt; NUM
    stall_timeout =&gt; NUM
            Optional. Passed directly to the underlying
            `Net::Async::HTTP-&gt;request' method.

  $f = $s3-&gt;list_bucket( %args )
    Requests a list of the keys in a bucket, optionally within some prefix.

    Takes the following named arguments:

    bucket =&gt; STR
            The name of the S3 bucket to query

    prefix =&gt; STR
    delimiter =&gt; STR
            Optional. If supplied, the prefix and delimiter to use to divide
            up the key namespace. Keys will be divided on the `delimiter'
            parameter, and only the key space beginning with the given
            prefix will be queried.

    The Future will return two ARRAY references. The first provides a list
    of the keys found within the given prefix, and the second will return a
    list of the common prefixes of further nested keys.

     ( $keys, $prefixes ) = $f-&gt;get

    Each key in the `$keys' list is given in a HASH reference containing

    key =&gt; STRING
            The key's name

    last_modified =&gt; STRING
            The last modification time of the key given in ISO 8601 format

    etag =&gt; STRING
            The entity tag of the key

    size =&gt; INT
            The size of the key's value, in bytes

    storage_class =&gt; STRING
            The S3 storage class of the key

    Each key in the `$prefixes' list is given as a plain string.

  $f = $s3-&gt;get_object( %args )
    Requests the value of a key from a bucket.

    Takes the following named arguments:

    bucket =&gt; STR
            The name of the S3 bucket to query

    key =&gt; STR
            The name of the key to query

    on_chunk =&gt; CODE
            Optional. If supplied, this code will be invoked repeatedly on
            receipt of more bytes of the key's value. It will be passed the
            HTTP::Response object received in reply to the request, and a
            byte string containing more bytes of the value. Its return value
            is not important.

             $on_chunk-&gt;( $header, $bytes )

            If this is supplied then the key's value will not be
            accumulated, and the final result of the Future will be an empty
            string.

    The Future will return a byte string containing the key's value, the
    HTTP::Response that was received, and a hash reference containing any of
    the metadata fields, if found in the response.

     ( $value, $response, $meta ) = $f-&gt;get;

    If an `on_chunk' code reference is passed, this string will be empty.

  $f = $s3-&gt;head_object( %args )
    Requests the value metadata of a key from a bucket. This is similar to
    the `get_object' method, but uses the `HEAD' HTTP verb instead of `GET'.

    Takes the same named arguments as `get_object', but will ignore an
    `on_chunk' callback, if provided.

    The Future will return the HTTP::Response object and metadata hash
    reference, without the content string (as no content is returned to a
    `HEAD' request).

     ( $response, $meta ) = $f-&gt;get;

  $f = $s3-&gt;put_object( %args )
    Sets a new value for a key in the bucket.

    Takes the following named arguments:

    bucket =&gt; STRING
            The name of the S3 bucket to put the value in

    key =&gt; STRING
            The name of the key to put the value in

    value =&gt; STRING
    value =&gt; Future giving STRING
            Optional. If provided, gives a byte string as the new value for
            the key or a Future which will eventually yield such.

    value =&gt; CODE
    value_length =&gt; INT
            Alternative form of `value', which is a `CODE' reference to a
            generator function. It will be called repeatedly to generate
            small chunks of content, being passed the position and length it
            should yield.

             $chunk = $value-&gt;( $pos, $len )

            Typically this can be provided either by a `substr' operation on
            a larger string buffer, or a `sysseek' and `sysread' operation
            on a filehandle.

            In normal operation the function will just be called in a single
            sweep in contiguous regions up to the extent given by
            `value_length'. If however, the MD5sum check fails at the end of
            upload, it will be called again to retry the operation. The
            function must therefore be prepared to be invoked multiple times
            over its range.

    gen_parts =&gt; CODE
            Alternative to `value' in the case of larger values, and implies
            the use of multipart upload. Called repeatedly to generate
            successive parts of the upload. Each time `gen_parts' is called
            it should return either a byte string containing the value for
            that part, a Future which will eventually yield a byte string,
            or a 2-element list consisting of a CODE reference to the part's
            generator function and the length in bytes that it will
            eventually yield.

             ( $value ) = $gen_parts-&gt;()

             ( $value_f ) = $gen_parts-&gt;(); $value = $value_f-&gt;get

             ( $gen_value, $value_length ) = $gen_parts-&gt;()

            Each case is analogous to the types that the `value' key can
            take.

    meta =&gt; HASH
            Optional. If provided, gives additional user metadata fields to
            set on the object, using the `X-Amz-Meta-' fields.

    The Future will return a single string containing the S3 ETag of the
    newly-set key. For single-part uploads this will be the MD5 sum in hex,
    surrounded by quote marks. For multi-part uploads this is a string in a
    different form, though details of its generation are not specified by
    S3.

     ( $etag ) = $f-&gt;get

    The returned MD5 sum from S3 during upload will be checked against an
    internally-generated MD5 sum of the content that was sent, and an error
    result will be returned if these do not match.

  $f = $s3-&gt;delete_object( %args )
    Deletes a key from the bucket.

    Takes the following named arguments:

    bucket =&gt; STRING
            The name of the S3 bucket to put the value in

    key =&gt; STRING
            The name of the key to put the value in

    The Future will return nothing.

SPONSORS
    Parts of this code were paid for by

    * Socialflow http://www.socialflow.com

    * Shadowcat Systems http://www.shadow.cat

AUTHOR
    Paul Evans &lt;leonerd@leonerd.org.uk&gt;

</pre></body></html>