III. Attachment Reference

Attachments, also known as blobs, can be used to administer and serve out arbitrary data with Midgard. This will typically be used for images, sounds, flash movies, etc. and for files available for download.

Attachments can be connected to any kind of resource, not just articles as with the Midgard file functions, and attachments to page records will be served out directly based on their name.

To prepare your setup for blobserving, create a directory to store the attached file, e.g. /home/httpd/blobs, and make sure the user that apache runs as (e.g. nobody) has read permission for this directory. Write permission is not necesary.

Within this directory, create the directories that the actual files will be stored in by executing:

mkdir `perl -e '@dirs = split(//, "0123456789ABCDEF"); foreach $l1 (@dirs) { print "$l1\n"; foreach $l2 (@dirs) { print "$l1/$l2\n"; } }'`
chown -R nobody *
chmod -R u+rwx *
  

In your httpd.conf, specify the blob directory:

MidgardBlobDir /home/httpd/blobs
  

1. Attachment Record Definition

An attachment record contains information about record attachments.

Fields of an attachment record

id

The id of the attachment record.

ptable

The name of the parent table the attachment belongs to.

pid

The id of the parent record within the table ptable

score

The score of the attachment.

name

The name of the attachment.

title

The title of the attachment.

location

The location of the attachment.

mimetype

The mimetype of the attachement.

sitegroup

The sitegroup the attachment belongs to.

author

The person-id of the author of the attachment.

created

Date and time the attachment record was created. Format is YYYY-MM-DD HH:mm:ss

2. Attachment Object Definition

Midgard functions like mgd_get_attachment return objects upon success. This section describes the contents of those objects.

The functions listed within the object definition are the object methods that are available for the object. Usage information about thos methods can be found in: Object Methods.

/* Attachment Object Prototype */

Class attachment {

 var $N;     # Only in objects created by calling $object->listattachments.
 var $id;
 var $ptable;
 var $pid;
 var $score;
 var $name;
 var $title;
 var $location;
 var $mimetype;
 var $sitegroup;
 var $author;
 var $created;

 function fetch(); # Only in objects created by calling $object->listattachments. 

 function delete();
 function update();

 function listparameters();
 function parameter();
 function searchparameters();

 function getsitegroup();
 function setsitegroup();
}
Table of Contents
mgd_delete_attachment — Delete an attachment
mgd_get_attachment — Get an attachment
mgd_open_attachment — Open a filehandle to an attachment
mgd_serve_attachment — Serve an attachment
mgd_update_attachment — Update an attachment
mgd_stat_attachment — Gives information about the attachment.