DIME::Payload(3pm)

DIME::Payload3pm

Implementation of a payload of a dime message

Usage

  # Create a standard DIME message from an existing file
  # and a string
  use DIME::Payload;
  $payload1 = DIME::Payload->new();
  $payload1->attach(Path => 'existingfile.jpg',
                    MIMEType => 'image/jpeg',
                    Dynamic => 1);
  $payload2 = DIME::Payload->new();
  my $data = 'Hello World!!!';
  $payload2->attach(Data => \$data,     
                    MIMEType => 'text/plain');
  my $message = DIME::Message->new();
  $message->add_payload($payload1);
  $message->add_payload($payload2);

Overview

DIME::Payload represents the content of DIME message. A message is composed of one or many Payload objects.

There are two types of DIME payloads: chunked and not chunked. A DIME message that isn't chunked has only one record with all the Payload content. A chunked message is splited in several records, allowing to sender and receiver process the content without know the total size of this.

Chunked and dynamic content

To create a chunked message you have to specify the Chunked key:

        # This create a dynamic payload with records of 16384 bytes
        my $payload = DIME::Payload->new();
        $payload->attach(Path => 'bigfile.avi',
                         Chunked => 16384,
                         Dynamic => 1);
        # You can encode all the payload at once:
        my $dime_encoded_message = ${$payload->print_data()};
        # Or, if you prefer, you can generate each chunk
        my $ret;
        do
        {
                $chunk = ${$payload->print_chunk_data()};
        } while ($chunk ne '');

The Dynamic key is used to avoid load all the file in memory. What DIME::Payload does is to open the file and, when it need more content, read from the file. If you don't set the Dynamic key, all the data is loaded in memory.

Content type

To specify the type of content of a Payload, you should use the MIMEType and URIType keys:

        # MIME media-type
        my $payload = DIME::Payload->new();
        $payload->attach(Path => 'image.jpg',
                         MIMEType => 'image/jpeg');
        # absolute URI 
        my $payload = DIME::Payload->new();
        $payload->attach(Path => 'message.xml',
                         URIType => 'http://schemas.xmlsoap.org/soap/envelope/');

Payload identifier

When you create a new Payload, a unique identifier is generated automatically. You can get/set it with the id() method:

        my $payload = DIME::Payload->new();
        print $payload->id();

Releases

6 releases since Debian 8 (Jessie); the text changed 2 times.

  1. 8
  2. 9–10
  3. 11–13

Author

Domingo Alcazar Larrea, <[email protected]>

From libdime-tools-perl 0.05-1 in Debian 13 (Trixie). Parsed by carta from the page's man source.