Guide Home
POD Home

Sloop::Multipart::Data

DESCRIPTION

Sloop::Multipart::Data objects are constructed by a Sloop::Multipart object for each part found in an HTTP multipart post body.

ATTRIBUTES

$mpd->{name}

The name of the part. This corresponds to the name attribute of the HTML input tag responsible for this part. Since some inputs can provide multiple parts, it is not necessarily unique in relation to other Sloop::Multipart::Data objects produced by the same request.

$mpd->{length}

This is the accumulated length of the content.

$mpd->{headers}

The HTTP protocol requires individual headers for each part; {headers} is a hash reference to them much like the one in a Sloop::Client::Request, except this is two tiered: 'content-disposition' is a sub hash. Note that $mpd->{headers}->{'content-disposition'}->{name} is the same as $mpd->{name}.

$mpd->{tmpfile}

The full pathname of the tmp file used to store content. This file is automatically deleted by $mpd->DESTROY when (e.g.) $mpd goes out of scope.

METHODS

$mpd->filename()

Retrieves the base filename of the part, if this a file upload.

Returns The file name, or undef.

$mpd->header($key)

Convenience method for retrieving a value from $mpd->{headers}.

$key is the name of the header.

$mpd->placeFile($filepath)

This will move (via File::Copy::move()) $mpd->{tmpfile} to a more permanent location.

$filepath is the full path to move the file to. The sloop process must have write permission to this location.

Returns 1 for success, 0 for failure.

$mpd->getContent()

Convenience method for getting the content, rather than dealing with $mpd->{tmpfile}. Do not call this method this after placeFile() or otherwise moving the {tmpfile}, or call it multiple times; {tmpfile} will be deleted after the call.

Returns The content of $mpd->{tmpfile}.

$mpd->size()

API call to retrieve the size of $mpd->{data} before the content is accessed. Afterward, this will return undef.

Returns For _MEM_ based objects, undef. Otherwise, the size in bytes of $mpd->{tmpfile}.