NAME

Podius::Property::Multimedia - Multimedia component property


SYNOPSIS

This is an abstract superclass.

Supposed to be used in the Podius::Component manpage and the Podius::Property manpage module trees only.


DESCRIPTION

This module implements general multimedia component property. It can be subclassed to add specific meaning to stored scalar raw data (possibly binary).

Multimedia properties manage 3 things:

  * binary raw-data
  * filename
  * label


REQUIREMENTS

the Podius::Property::Publishable manpage, the Exception manpage.

new

description
Class constructor.

parameters
The same as in superclass. Class name and optional parameters:
  * hashref (may be omitted) with keys 'prefix' or others
  * default filename
  * default label
  * scalarref raw-data

returns
New property object.

new_from_serialized

description
Class constructor. Used for deserialization.

parameters
Class name (like all constructors) and array ref [ content_ref, filename, label ]. Additional parameters are property static parameters (if any).

returns
New property object.


METHODS

serialize

description
Used for serialization.

returns
String (in this case array ref), representing the property, from which the property can be restored later by new_from_serialized constructor.

access

parameters
Accessor: none.

Modifier: property value to set (raw-data-ref) - ref to scalar. ref to undef means unset the value.

returns
Property value (raw-data-ref) - ref to scalar. ref to undef means no property value is set.

access_label

parameters
Accessor: none.

Modifier: scalar (label).

returns
Scalar (label).

access_filename

parameters
Accessor: none.

Modifier: scalar (file-name).

returns
Scalar (file-name).

access_basename

parameters
Accessor: none.

Modifier: scalar (base-name, last element of file-name, see access_filename).

returns
Scalar (base-name, last element of file-name, see access_filename).

access_content

parameters
None.

Only accessor form is available.

returns
Possibly long and binary string of the multimedia content.

access_defined

parameters
None.

Only accessor form is available.

returns
0 or 1 depending on whether multimedia data is set or not.

access_size

parameters
None.

Only accessor form is available.

returns
Integer that is the size of the multimedia content.

init_from_file

description
This method replaces the property data with the contents of the local file.

If file does not exists, then the property is not touched and undef is returned.

parameters
  * mandatory filename
  * optional label (by default it is constructed from filename)
returns
Self on success, undef on failure to load file. It is possible the exception is thrown on file-system problems (should not usually happen).

init_from_url

description
This method replaces the property data with the file fetched from the given url using LWP::Simple::get.

If url is broken, then the property is not touched and undef is returned.

parameters
  * mandatory url
  * optional label (by default it is constructed from filename)
returns
Self on success, undef on failure to fetch url.

init_from_web_upload

description
This method replaces the property data with the web-uploaded file using the multipart/form-data web mechanism.

If no file was uploaded, then the property is not touched and undef is returned.

parameters
  * optional form param name (by default the property name is used)
  * optional label (by default it is constructed from filename)
returns
Self on success, undef on no file uploaded.

reset

description
This method removes the property data.

parameters
None.

returns
Self.