Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions atlassian/confluence.py
Original file line number Diff line number Diff line change
Expand Up @@ -1470,8 +1470,7 @@ def download_attachments_from_page(self, page_id, path=None, start=0, limit=50,
file_name = attachment["title"] or attachment["id"] # Use attachment ID if title is unavailable
download_link = self.url + attachment["_links"]["download"]
# Fetch the file content
response = self._session.get(str(download_link))
response.raise_for_status() # Raise error if request fails
response = self.get(str(download_link))

if to_memory:
# Store in BytesIO object
Expand All @@ -1493,7 +1492,11 @@ def download_attachments_from_page(self, page_id, path=None, start=0, limit=50,
except PermissionError:
raise PermissionError("Permission denied when trying to save files to '{path}'.".format(path=path))
except requests.HTTPError as http_err:
raise Exception("HTTP error occurred while downloading attachments: {http_err}".format(http_err=http_err))
raise requests.HTTPError(
"HTTP error occurred while downloading attachments: {http_err}".format(http_err=http_err),
response=http_err.response,
request=http_err.request
)
except Exception as err:
raise Exception("An unexpected error occurred: {error}".format(error=err))

Expand Down
10 changes: 10 additions & 0 deletions atlassian/jira.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,16 @@ def get_attachment(self, attachment_id):
url = "{base_url}/{attachment_id}".format(base_url=base_url, attachment_id=attachment_id)
return self.get(url)

def download_issue_attachments(self, issue, path=None):
"""
Downloads all attachments from a Jira issue.
:param issue: The issue-key of the Jira issue
:param path: Path to directory where attachments will be saved. If None, current working directory will be used.
:return: A message indicating the result of the download operation.
"""
return self.download_attachments_from_issue(issue=issue, path=path, cloud=self.cloud)

@deprecated(version="3.41.20", reason="Use download_issue_attachments instead")
def download_attachments_from_issue(self, issue, path=None, cloud=True):
"""
Downloads all attachments from a Jira issue.
Expand Down
Loading