BZ::Cl...achment(3pm)
πΈ NAME πΈ
okay bestie, welcome to BZ::Client::Bug::Attachment(3pm) from the User Contributed Perl Documentation π
β this is the class that does Client side representation of an Attachment to a Bug in Bugzilla.
π VERSION π
version 4.91.
β¨ SYNOPSIS β¨
This class provides methods for accessing and managing attachments in Bugzilla. Instances of this class are returned by BZ::Client::Bug::Attachment::get.
my $client = BZ::Client->new(
url => $url,
user => $user,
password => $password
);
my $comments = BZ::Client::Bug::Attachment->get( $client, $ids );
yes, the variable is $comments even though we're doing attachments β iconic, no notes π
π«Ά CLASS METHODS π«Ά
This section lists the class methods, which are available in this module.
π get π
This one lets you get data about attachments, given a list of bugs and/or attachment ids.
Note: Private attachments will only be returned if you are in the insidergroup or if you are the submitter of the attachment.
Actual Bugzilla API method is attachments.
π History
Added in Bugzilla 3.6.
π§Ύ Parameters
Note: At least one ofidsorattachment_idsis required.
In addition to the parameters below, this method also accepts the standard include_fields in BZ::Client::Bug and exclude_fields in BZ::Client::Bug arguments.
idsβids(array) β An array that can contain both bug IDs and bug aliases. All of the attachments (that are visible to you) will be returned for the specified bugs.attachment_idsβattachment_ids(array) β An array of integer attachment ID's.
π¦ Returns
A hash containing two items is returned:
bugsβ This is used for bugs specified inids. This is a hash, where the keys are the numeric ID's of the bugs and the value is an array of attachment obejcts.
Note that any individual bug will only be returned once, so if you specify an ID multiple times in ids, it will still only be returned once.
attachmentsβ Each individual attachment requested inattachment_idsis returned here, in a hash where the numericattachment_idis the key, and the value is the attachment object.
The return value looks like this:
{
bugs => {
1345 => [
{ (attachment) },
{ (attachment) }
],
9874 => [
{ (attachment) },
{ (attachment) }
],
},
attachments => {
234 => { (attachment) },
123 => { (attachment) },
},
}
An attachment as shown above is an object instance of this package.
π₯ Errors
100- Invalid Bug Alias β If you specified an alias and there is no bug with that alias.101- Invalid Bug ID β Thebug_idyou specified doesn't exist in the database.102- Access Denied β You do not have access to thebug_idyou specified.304- Auth Failure, Attachment is Private β You specified the ID of a private attachment in theattachment_idsargument, and you are not in theinsidergroupthat can see private attachments.
π₯ add π₯
This allows you to add an attachment to a bug in Bugzilla.
Actual Bugzilla API method is add_attachment.
π History
Added in Bugzilla 4.0.
The return value has changed in Bugzilla 4.4.
π§Ύ Parameters
An instance of this package or a hash containing:
idsβids(array) Required β An array of ints and/or strings β the ID's or aliases of bugs that you want to add this attachment to. The same attachment and comment will be added to all these bugs.dataβdata(string or base64) Mostly Required β The content of the attachment.
The content will be base64 encoded. Or you can do it yourself by providing this option as a BZ::Client::XMPRPC::base64 object.
What is "Mostly Required" you ask? If you provide file_name only, this module will attempt to slurp it to provide this data parameter. See file_name options for more details.
file_nameβfile_name(string) Required β The "file name" that will be displayed in the UI for this attachment.
If no /data parameter is provided, this module will attempt to open, slurp the contents of a file with path file_name, base64-encodes that data, puts it into the /data parameter, then file_name is truncated to just the file's basename.
Failures to open the file (for any reason) will be silently ignored and the file_name parameter will not be touched.
summaryβsummary(string) Required β A short string describing the attachment.content_typeβcontent_type(string) Required β The MIME type of the attachment, liketext/plainorimage/png.commentβcomment(string) β A comment to add along with this attachment.is_patchβis_patch(boolean) β True if Bugzilla should treat this attachment as a patch. If you specify this, you do not need to specify acontent_type. Thecontent_typeof the attachment will be forced totext/plain.
Defaults to False if not specified.
is_privateβis_private(boolean) β True if the attachment should be private (restricted to theinsidergroup), False if the attachment should be public.
Defaults to False if not specified.
flagsβ An array of hashes with flags to add to the attachment. To create a flag, at least thestatusand thetype_idornamemust be provided. An optional requestee can be passed if the flag type is requestable to a specific user.nameβname(string) β The name of the flag type.type_idβtype_id(int) β THe internal flag type ID.statusβstatus(string) β The flags new status (i.e.?,+,-orXto clear a flag).requesteeβrequestee(string) β The login of the requestee if the flag type is requestable to a specific user.
π¦ Returns
An array of the attachment ID's created.
π₯ Errors
100- Invalid Bug Alias β If you specified an alias and there is no bug with that alias.101- Invalid Bug ID β Thebug_idyou specified doesn't exist in the database.102- Access Denied β You do not have access to thebug_idyou specified.129- Flag Status Invalid β The flag status is invalid.130- Flag Modification Denied β You tried to request, grant, or deny a flag but only a user with the required permissions may make the change.131- Flag not Requestable from Specific Person β You can't ask a specific person for the flag.133- Flag Type not Unique β The flag type specified matches several flag types. You must specify the type id value to update or add a flag.134- Inactive Flag Type β The flag type is inactive and cannot be used to create new flags.600- Attachment Too Large β You tried to attach a file that was larger than Bugzilla will accept.601- Invalid MIME Type β You specified acontent_typeargument that was blank, not a valid MIME type, or not a MIME type that Bugzilla accepts for attachments.603- File Name Not Specified β You did not specify a valid value for thefile_nameargument.604- Summary Required β You did not specify a value for thesummaryargument.606- Empty Data β You set thedatafield to an empty string.
π¦ render π¦
Returns the HTML rendering of the provided comment text.
Actual Bugzilla API method is render_comment.
Note: this all takes place on your Bugzilla server.
π History
Added in Bugzilla 5.0.
π§Ύ Parameters
textβtext(string) Required β Text comment text to render.idβidβ The ID of the bug to render the comment against.
π¦ Returns
The HTML rendering.
π₯ Errors
100- Invalid Bug Alias β If you specified an alias and there is no bug with that alias.101- Invalid Bug ID β Thebug_idyou specified doesn't exist in the database.102- Access Denied β You do not have access to thebug_idyou specified.
π update π
This allows you to update attachment metadata in Bugzilla.
Actual Bugzilla API method is update_attachments.
π History
Added in Bugzilla 5.0.
π§Ύ Parameters
idsβids(array) β An array that can contain both bug IDs and bug aliases. All of the attachments (that are visible to you) will be returned for the specified bugs.file_nameβfile_name(string) Required β The "file name" that will be displayed in the UI for this attachment.summaryβsummary(string) Required β A short string describing the attachment.commentβcomment(string) β A comment to add along with this attachment.content_typeβcontent_type(string) β The MIME type of the attachment, liketext/plainorimage/png.is_patchβis_patch(boolean) β True if Bugzilla should treat this attachment as a patch. If you specify this, you do not need to specify acontent_type. Thecontent_typeof the attachment will be forced totext/plain.is_privateβis_private(boolean) β True if the attachment should be private (restricted to theinsidergroup), False if the attachment should be public.is_obsoleteβis_obsolete(boolean) β True if the attachment is obsolete, False otherwise.flagsβ An array of hashes with flags to add to the attachment. To create a flag, at least thestatusand thetype_idornamemust be provided. An optional requestee can be passed if the flag type is requestable to a specific user.nameβname(string) β The name of the flag type.type_idβtype_id(int) β THe internal flag type id.statusβstatus(string) β The flags new status (i.e.?,+,-orXto clear a flag).requesteeβrequestee(string) β The login of the requestee if the flag type is requestable to a specific user.idβid(int) β Useidto specify the flag to be updated. You will need to specify theidif more than one flag is set of the same name.newβnew(boolean) β Set to true if you specifically want a new flag to be created.
π¦ Returns
An array of hashes with the following fields:
idβid(int) β The id of the attachment that was updated.last_change_timeβlast_change_time(DateTime) β The exact time that this update was done at, for this attachment. If no update was done (that is, no fields had their values changed and no comment was added) then this will instead be the last time the attachment was updated.
changes π¦
changes (hash) β the changes that were actually done on this bug. The keys are the names of the fields that were changed, and the values are a hash with two keys:
addedβadded(string): the values that were added to this field. Possibly a comma-and-space-separated list if multiple values were added. β¨removedβremoved(string): the values that were removed from this field. π
Here's an example of what a return value might look like:
[
{
id => 123,
last_change_time => '2010-01-01T12:34:56',
changes => {
summary => {
removed => 'Sample ptach',
added => 'Sample patch'
},
is_obsolete => {
removed => '0',
added => '1',
},
},
},
]
Errors π
100β Invalid Bug Alias β if you specified an alias and there is no bug with that alias.101β Invalid Bug ID β thebug_idyou specified doesn't exist in the database.102β Access Denied β you do not have access to thebug_idyou specified.129β Flag Status Invalid β the flag status is invalid.130β Flag Modification Denied β you tried to request, grant, or deny a flag, but only a user with the required permissions may make the change.131β Flag not Requestable from Specific Person β you can't ask a specific person for the flag.133β Flag Type not Unique β the flag type specified matches several flag types. You must specify the type ID value to update or add a flag.134β Inactive Flag Type β the flag type is inactive and cannot be used to create new flags.601β Invalid MIME Type β you specified acontent_typeargument that was blank, not a valid MIME type, or not a MIME type that Bugzilla accepts for attachments.603β File Name Not Specified β you did not specify a valid value for thefile_nameargument.604β Summary Required β you did not specify a value for thesummaryargument.
Periodt. π
new π±
my $comment = BZ::Client::Bug::Comment->new(
id => $bug_id,
comment => $comment,
is_private => 1 || 0,
work_time => 3.5
);
Creates a new instance with the given details. Doesn't actually touch your Bugzilla Server β see add for that. β¨
INSTANCE METHODS π
This section lists the module's instance methods.
bug_id π
bug_id (int) β the ID of the bug that this attachment is on when reading.
bug_id (int or string) β the ID or alias of the bug to append an attachment to when writing. Required.
data π
data (base64 or string) β the content of the attachment.
When writing, either provide a string (which will be base46 encoded for you) or a BZ::Client::XMLRPC::base64 object if you'd like to DIY.
When reading, a BZ::Client::XMLRPC::base64 object will be returned. To save you the trip, this object has a raw() and a base64() method. Here is an example.
my $data = $attachment->data();
my $file_content_base64_encoded = $data->base64();
my $original_file_content = $data->raw();
Required, Read and Write.
file_name π
file_name (string) β the "file name" that will be displayed in the UI for this attachment.
Required, Read and Write.
summary π
summary (string) β a short string describing the attachment.
Required, Read and Write.
content_type π
content_type (string) β the MIME type of the attachment, like text/plain or image/png.
Required, Read and Write.
comment π¬
comment (string or hash) β a comment to add along with this attachment. If comment is a hash, it has the following keys:
Only useful when adding attachments.
bodyβbody(string): the body of the comment.is_markdownβis_markdown(boolean): if set to true, the comment has Markdown structures; otherwise, it is ordinary text.
is_patch π©Ή
is_patch (boolean) β True if the attachment should be private (restricted to the insidergroup), False if the attachment should be public. Yes bestie, that's literally what the doc says β I'm just the messenger π.
is_private π
is_private (boolean) β True if the attachment is private (only visible to a certain group called the insidergroup), False otherwise.
is_obsolete ποΈ
is_obsolete (boolean) β True if the attachment is obsolete, False otherwise.
flags π©
flags (array) β an array of hashes with flags to add to the attachment. To create a flag, at least the status and the type_id or name must be provided. An optional requestee can be passed if the flag type is requestable to a specific user.
Read and Write.
idβid(name) β the ID of the flag.nameβname(string) β the name flag type. Read and Write.type_idβtype_id(int) β the internal flag type ID. Read and Write.creation_dateβcreation_date(DateTime) β the timestamp when this flag was originally created. Read only.modification_dateβmodification_date(DateTime) β the timestamp when the flag was last modified. Read only.statusβstatus(string) β the flag's new status (i.e.?,+,-orXto clear a flag). Read and Write.setterβsetter(string) β the login name of the user who created or last modified the flag. Read only.requesteeβrequestee(string) β the login of the requestee if the flag type is requestable to a specific user.
size π
size (int) β the length (in bytes) of the attachment.
Read only.
creation_time β°
creation_time (DateTime) β the time the attachment was created.
Read only.
last_change_time π°οΈ
last_change_time (DateTime) β the last time the attachment was modified.
attachment_id π
attachment_id (int) β the numeric id of the attachment.
creator π€
creator (string) β the login name of the user that created the attachment.
AUTHORS π
Dean Hamstead <dean@bytefoundry.com.au>Jochen Wiedmann <jochen.wiedmann@gmail.com>
COPYRIGHT AND LICENSE π
This software is copyright (c) 2026 by Dean Hamstad.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
π That's the whole page, bestie β from perl v5.40.2, dated 2026-07-16, and it's BZ::Cl...achment(3pm). Slay. π«Ά
π¦ where this page comes from
- epel 10: perl-BZ-Client 4.9100-2.el10_3 Β· GPL-1.0-or-later OR Artistic-1.0-Perl
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms