| blib/lib/Prancer/Request/Upload.pm | |||
|---|---|---|---|
| Criterion | Covered | Total | % |
| statement | 20 | 22 | 90.9 |
| branch | n/a | ||
| condition | n/a | ||
| subroutine | 8 | 9 | 88.8 |
| pod | 4 | 5 | 80.0 |
| total | 32 | 36 | 88.8 |
| line | stmt | bran | cond | sub | pod | time | code |
|---|---|---|---|---|---|---|---|
| 1 | package Prancer::Request::Upload; | ||||||
| 2 | |||||||
| 3 | 3 | 3 | 12 | use strict; | |||
| 3 | 5 | ||||||
| 3 | 99 | ||||||
| 4 | 3 | 3 | 11 | use warnings FATAL => 'all'; | |||
| 3 | 3 | ||||||
| 3 | 125 | ||||||
| 5 | |||||||
| 6 | 3 | 3 | 11 | use version; | |||
| 3 | 5 | ||||||
| 3 | 16 | ||||||
| 7 | our $VERSION = '1.02'; | ||||||
| 8 | |||||||
| 9 | 3 | 3 | 201 | use Carp; | |||
| 3 | 5 | ||||||
| 3 | 525 | ||||||
| 10 | |||||||
| 11 | # even though this *should* work automatically, it was not | ||||||
| 12 | our @CARP_NOT = qw(Prancer Try::Tiny); | ||||||
| 13 | |||||||
| 14 | sub new { | ||||||
| 15 | 3 | 3 | 0 | 4 | my ($class, $upload) = @_; | ||
| 16 | 3 | 13 | return bless({ '_upload' => $upload }, $class); | ||||
| 17 | } | ||||||
| 18 | |||||||
| 19 | sub filename { | ||||||
| 20 | 1 | 1 | 1 | 247 | my $self = shift; | ||
| 21 | 1 | 8 | return $self->{'_upload'}->filename(); | ||||
| 22 | } | ||||||
| 23 | |||||||
| 24 | sub size { | ||||||
| 25 | 1 | 1 | 1 | 337 | my $self = shift; | ||
| 26 | 1 | 5 | return $self->{'_upload'}->size(); | ||||
| 27 | } | ||||||
| 28 | |||||||
| 29 | sub path { | ||||||
| 30 | 0 | 0 | 1 | 0 | my $self = shift; | ||
| 31 | 0 | 0 | return $self->{'_upload'}->path(); | ||||
| 32 | } | ||||||
| 33 | |||||||
| 34 | sub content_type { | ||||||
| 35 | 1 | 1 | 1 | 287 | my $self = shift; | ||
| 36 | 1 | 6 | return $self->{'_upload'}->content_type(); | ||||
| 37 | } | ||||||
| 38 | |||||||
| 39 | 1; | ||||||
| 40 | |||||||
| 41 | =head1 NAME | ||||||
| 42 | |||||||
| 43 | Prancer::Request::Upload | ||||||
| 44 | |||||||
| 45 | =head1 SYNOPSIS | ||||||
| 46 | |||||||
| 47 | Uploads come from the L |
||||||
| 48 | can be used like this: | ||||||
| 49 | |||||||
| 50 | # in your HTML | ||||||
| 51 | |||||||
| 52 | |||||||
| 53 | |||||||
| 54 | |||||||
| 55 | # in the Prancer handler | ||||||
| 56 | my $upload = $request->upload("foo"); | ||||||
| 57 | |||||||
| 58 | =head1 METHODS | ||||||
| 59 | |||||||
| 60 | =over | ||||||
| 61 | |||||||
| 62 | =item size | ||||||
| 63 | |||||||
| 64 | Returns the size of uploaded file. | ||||||
| 65 | |||||||
| 66 | =item path | ||||||
| 67 | |||||||
| 68 | Returns the path to the temporary file where uploaded file is saved. | ||||||
| 69 | |||||||
| 70 | =item content_type | ||||||
| 71 | |||||||
| 72 | Returns the content type of the uploaded file. | ||||||
| 73 | |||||||
| 74 | =item filename | ||||||
| 75 | |||||||
| 76 | Returns the original filename in the client. | ||||||
| 77 | |||||||
| 78 | =back | ||||||
| 79 | |||||||
| 80 | =cut |