Uniform::Upload::PAGI

CPAN version License: MIT

Asynchronous PAGI framework adapter for Uniform::Upload.

Uniform::Upload::PAGI bridges asynchronous PAGI application HTTP request streams with the Uniform::Upload file validation and extraction engine.

Installation

Install using cpanm or your preferred CPAN client:

cpanm Uniform::Upload::PAGI

Synopsis

use Uniform::Upload::PAGI;

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

# Asynchronously read payload stream and extract wrapped file objects
$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 "Upload invalid: " . $file->error;
        }
    }
});

Running the Example

Run the included PAGI upload simulation script:

perl -Ilib examples/demo.pl

Local Development & Testing

Execute the test suite using prove:

prove -Ilib -v t/

This software is Copyright (c) 2026 by Joshua S. Day <HAX@cpan.org>.

This is free software, licensed under:

The MIT (X11) License