Skip to content

Commit b9852b8

Browse files
authored
[Jira, Confluence] Minor changes (#1503)
1 parent 152285a commit b9852b8

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

atlassian/confluence.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1470,8 +1470,7 @@ def download_attachments_from_page(self, page_id, path=None, start=0, limit=50,
14701470
file_name = attachment["title"] or attachment["id"] # Use attachment ID if title is unavailable
14711471
download_link = self.url + attachment["_links"]["download"]
14721472
# Fetch the file content
1473-
response = self._session.get(str(download_link))
1474-
response.raise_for_status() # Raise error if request fails
1473+
response = self.get(str(download_link))
14751474

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

atlassian/jira.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,16 @@ def get_attachment(self, attachment_id):
242242
url = "{base_url}/{attachment_id}".format(base_url=base_url, attachment_id=attachment_id)
243243
return self.get(url)
244244

245+
def download_issue_attachments(self, issue, path=None):
246+
"""
247+
Downloads all attachments from a Jira issue.
248+
:param issue: The issue-key of the Jira issue
249+
:param path: Path to directory where attachments will be saved. If None, current working directory will be used.
250+
:return: A message indicating the result of the download operation.
251+
"""
252+
return self.download_attachments_from_issue(issue=issue, path=path, cloud=self.cloud)
253+
254+
@deprecated(version="3.41.20", reason="Use download_issue_attachments instead")
245255
def download_attachments_from_issue(self, issue, path=None, cloud=True):
246256
"""
247257
Downloads all attachments from a Jira issue.

0 commit comments

Comments
 (0)