Bugzilla::Attachment - Bugzilla attachment class.
use Bugzilla::Attachment; # Get the attachment with the given ID. my $attachment = new Bugzilla::Attachment($attach_id); # Get the attachments with the given IDs. my $attachments = Bugzilla::Attachment->new_from_list($attach_ids);
Attachment.pm represents an attachment object. It is an implementation of Bugzilla::Object, and thus provides all methods that Bugzilla::Object provides.
The methods that are specific to
Bugzilla::Attachment are listed below.
the ID of the bug to which the attachment is attached
the bug object to which the attachment is attached
user-provided text describing the attachment
the attachment's MIME media type
the user who attached the attachment
the date and time on which the attacher attached the attachment
the date and time on which the attachment was last modified.
the name of the file the attacher attached
whether or not the attachment is a patch
whether or not the attachment is a URL
whether or not the attachment is obsolete
whether or not the attachment is private
Returns 1 if the attachment has a content-type viewable in this browser. Note that we don't use $cgi->Accept()'s ability to check if a content-type matches, because this will return a value even if it's matched by the generic */* which most browsers add to the end of their Accept: headers.
the content of the attachment
the length (in characters) of the attachment content
flags that have been set on the attachment
Return all flag types available for this attachment as well as flags already set, grouped by flag type.
Description: retrieves and returns the attachments the currently logged in user can view for the given bug.
$bug_id - integer - the ID of the bug for which to retrieve and return attachments.
Returns: a reference to an array of attachment objects.
Description: validates if the user is allowed to view and edit the attachment. Only the submitter or someone with editbugs privs can edit it. Only the submitter and users in the insider group can view private attachments.
Params: $attachment - the attachment object being edited. $product_id - the product ID the attachment belongs to.
Returns: 1 on success, 0 otherwise.
Description: validates if attachments the user wants to mark as obsolete really belong to the given bug and are not already obsolete. Moreover, a user cannot mark an attachment as obsolete if he cannot view it (due to restrictions on it).
Params: $bug - The bug object obsolete attachments should belong to. $attach_ids - The list of attachments to mark as obsolete.
Returns: The list of attachment objects to mark as obsolete. Else an error is thrown.
Description: inserts an attachment into the given bug.
Params: takes a hashref with the following keys:
bug - Bugzilla::Bug object - the bug for which to insert the attachment.
data - Either a filehandle pointing to the content of the attachment, or the content of the attachment itself.
description - string - describe what the attachment is about.
filename - string - the name of the attachment (used by the browser when downloading it). If the attachment is a URL, this parameter has no effect.
mimetype - string - a valid MIME type.
creation_ts - string (optional) - timestamp of the insert as returned by SELECT LOCALTIMESTAMP(0).
ispatch - boolean (optional, default false) - true if the attachment is a patch.
isprivate - boolean (optional, default false) - true if the attachment is private.
isurl - boolean (optional, default false) - true if the attachment is a URL pointing to some external ressource.
store_in_file - boolean (optional, default false) - true if the attachment must be stored in data/attachments/ instead of in the DB.
Returns: The new attachment object.
Description: removes an attachment from the DB.