NAME
Courriel::Disposition - The content disposition for an email part
VERSION
version 0.17
SYNOPSIS
my $disp = $part->content_disposition();
print $disp->is_inline();
print $disp->is_attachment();
print $disp->filename();
my %attr = $disp->attributes();
while ( my ( $k, $v ) = each %attr ) {
print "$k => $v\n";
}
DESCRIPTION
This class represents the contents of a "Content-Disposition" header attached to an email part. Such headers indicate whether or not a part should be considered an attachment or should be displayed to the user directly. This header may also include information about the attachment's filename, creation date, etc.
Here are some typical headers:
Content-Disposition: inline
Content-Disposition: multipart/alternative; boundary=abcdefghijk
Content-Disposition: attachment; filename="Filename.jpg"
Content-Disposition: attachment; filename="foo-bar.jpg";
creation-date="Tue, 31 May 2011 09:41:13 -0700"
API
This class supports the following methods:
Courriel::Disposition->new( ... )
This method creates a new object. It accepts the following parameters:
disposition
This should usually either be "inline" or "attachment".
In theory, the RFCs allow other values.
attributes
A hash reference of attributes from the header, such as a filename, creation date, size, etc. This is optional, and can be empty.
$disp->disposition()
Returns the disposition value passed to the constructor.
$disp->is_inline()
Returns true if the disposition is not equal to "attachment".
$disp->is_attachment()
Returns true if the disposition is equal to "attachment".
$disp->filename()
Returns the filename found in the attributes, or undef
.
$disp->creation_datetime(), $disp->last_modified_datetime(), $disp->read_datetime()
These methods look for a corresponding attribute ("creation-date", etc.) and return a DateTime object representing that attribute's value, if it exists.
$disp->attributes()
Returns a hash (not a reference) of the attributes passed to the constructor.
$disp->get_attribute($key)
Given a key, returns the value of the named attribute. Obviously, this value can be undef
if the attribute doesn't exist.
$disp->as_header_value()
Returns the object as a string suitable for a header value (but not folded).
AUTHOR
Dave Rolsky <autarch@urth.org>
COPYRIGHT AND LICENSE
This software is Copyright (c) 2011 by Dave Rolsky.
This is free software, licensed under:
The Artistic License 2.0 (GPL Compatible)