NAME

Uniform::Upload::PAGI - Async PAGI framework adapter for Uniform::Upload

SYNOPSIS

use Uniform::Upload::PAGI;

# Initialize driver with a PAGI scope and upload constraints
my $uploader = Uniform::Upload::PAGI->new(
    $scope,
    max_size      => '10MB',
    allowed_types => [qw( image/png image/jpeg application/pdf )],
);

# Parse PAGI stream asynchronously
$uploader->extract_async($receive)->then(sub {
    my ($files) = @_; # Arrayref of Uniform::Upload::File objects

    for my $file (@$files) {
        if ($file->is_valid) {
            $file->copy_to('/var/uploads/' . $file->sanitized_filename);
        } else {
            warn "Invalid upload: " . $file->error;
        }
    }
});

DESCRIPTION

Uniform::Upload::PAGI inherits directly from Uniform::Upload. It bridges asynchronous PAGI application streams with the Uniform::Upload file validation engine and wraps extracted files into Uniform::Upload::File instances.

METHODS

new

my $uploader = Uniform::Upload::PAGI->new($scope, %options);
# or
my $uploader = Uniform::Upload::PAGI->new(scope => $scope, %options);

Constructs a new PAGI driver instance. Delegates configuration parsing and state setup to "new" in Uniform::Upload via SUPER::new.

extract_async

my $future = $uploader->extract_async($receive);

Asynchronously parses the incoming PAGI multi-part body stream from the configured scope. Returns a Future that resolves to an array reference of validated Uniform::Upload::File instances.

INHERITED METHODS

This package inherits directly from Uniform::Upload. The following base methods are available:

  • wrap(%file_args)

  • max_size

  • allowed_types

  • file_class

SEE ALSO

AUTHOR

Joshua S. Day <HAX@cpan.org>

LICENSE AND COPYRIGHT

This software is Copyright (c) 2026 by Joshua S. Day.

This is free software, licensed under:

The MIT (X11) License