BZ::Cl...achment(3pm)

πŸ“¦
version 4.9100 Β· 4 versions
, in epel 10

🌸 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 of ids or attachment_ids is 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 in ids. 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 in attachment_ids is returned here, in a hash where the numeric attachment_id is 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 β€” The bug_id you specified doesn't exist in the database.
  • 102 - Access Denied β€” You do not have access to the bug_id you specified.
  • 304 - Auth Failure, Attachment is Private β€” You specified the ID of a private attachment in the attachment_ids argument, and you are not in the insidergroup that 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, like text/plain or image/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 a content_type. The content_type of the attachment will be forced to text/plain.

Defaults to False if not specified.

  • is_private β€” is_private (boolean) β€” True if the attachment should be private (restricted to the insidergroup), 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 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.
    • 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. ?, +, - or X to 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 β€” The bug_id you specified doesn't exist in the database.
  • 102 - Access Denied β€” You do not have access to the bug_id you 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 a content_type argument 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 the file_name argument.
  • 604 - Summary Required β€” You did not specify a value for the summary argument.
  • 606 - Empty Data β€” You set the data field 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 β€” The bug_id you specified doesn't exist in the database.
  • 102 - Access Denied β€” You do not have access to the bug_id you 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, like text/plain or image/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 a content_type. The content_type of the attachment will be forced to text/plain.
  • is_private β€” is_private (boolean) β€” True if the attachment should be private (restricted to the insidergroup), 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 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.
    • 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. ?, +, - or X to clear a flag).
    • requestee β€” requestee (string) β€” The login of the requestee if the flag type is requestable to a specific user.
    • id β€” id (int) β€” Use id to specify the flag to be updated. You will need to specify the id if 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 β€” the bug_id you specified doesn't exist in the database.
  • 102 β€” Access Denied β€” you do not have access to the bug_id you 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 a content_type argument 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 the file_name argument.
  • 604 β€” Summary Required β€” you did not specify a value for the summary argument.

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. ?, +, - or X to 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>

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