attachment_data: Get Files Attached to Bug Reports

View source: R/attachments.R

attachment_dataR Documentation

Get Files Attached to Bug Reports

Description

Gets the attachments of a single bug or any single attachment selected by its ID. By default, the R bug tracker is queried.

Usage

attachment_data(
  bug_id,
  attachment_id = NULL,
  obsolete = FALSE,
  patch_only = FALSE,
  output_dir = NULL,
  output_file = NULL,
  base_url = "https://bugs.r-project.org/bugzilla3/rest/bug/"
)

Arguments

bug_id

ID of one bug (numeric or character).

attachment_id

Optional ID of one attachment (numeric or character). If given, bug_id is ignored.

obsolete

Return information about attachments marked as obsolete? A logical flag. Default is FALSE, i.e., drop obsolete attachments. Ignored when attachment_id is given.

patch_only

Only return information about files marked as a patch? A logical flag. Default is FALSE, i.e., include all kinds of attachments. Ignored when attachment_id is given.

output_dir

file system directory where attachments will be saved (character string). If necessary, this function will create one directory level.

output_file

name of file where the attachment will be saved (character string). Only takes effect if attachment_id is used instead of bug_id.

base_url

URL to Bugzilla REST API (bug history). Defaults to R Bugzilla.

Value

If output_dir or output_file is specified, the function writes to the file system and invisibly returns the output_dir or output_file parameter (the one that is actually used). Otherwise returns a list containing the attachments as either raw vectors or character strings, depending on the file type. The list has the following vector attributes with one item corresponding to each attachment:

"file_name"

Name of file (character).

"is_patch"

Is the file marked as a patch? (logical)

"content_type"

MIME type of file (character).

Examples

## Not run: 
# Get attachments related to a bug
data17398b <- attachment_data(17398)

# Get a single attachment
data2328a <- attachment_data(attachment_id = 2328)

# Save files to a temporary directory
dir17148 <- attachment_data(17148, output_dir = tempfile(pattern = "dir"))
unlink(dir17148, recursive = TRUE)

# With and without obsolete files (different code paths used)
data16895b2 <- attachment_data(16895, obsolete = TRUE)
data16895b <- attachment_data(16895)
all(data16895b %in% data16895b2)

## End(Not run)

mvkorpel/bugtractr documentation built on Aug. 31, 2022, 1:16 p.m.