File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -403,19 +403,27 @@ def get_all_attachment_contents(
403403 try :
404404 if path is None :
405405 path = os .getcwd ()
406- issue_id = self .issue (issue , fields = "id" )["id" ]
406+ issue_data = self .issue (issue , fields = "id,attachment" )
407+ issue_id = issue_data ["id" ]
407408 attachment_name = f"{ issue_id } _attachments.zip"
408409 file_path = os .path .join (path , attachment_name )
409410 if not overwrite and os .path .isfile (file_path ):
410411 return file_path
411412
412- attachments_metadata = self . get_attachments_ids_from_issue ( issue )
413+ attachments_metadata = issue_data [ "fields" ][ "attachment" ]
413414 if not attachments_metadata :
414415 return None
415416
416417 with zipfile .ZipFile (file_path , "w" , compression = compression ) as file :
417418 for meta in attachments_metadata :
418- file .writestr (meta ["filename" ], self .get_attachment_content (meta ["attachment_id" ]))
419+ # stream download should not be used, as writestr expects full content with filename.
420+ content = self .get (
421+ meta ["content" ],
422+ not_json_response = True ,
423+ absolute = True ,
424+ headers = {"Accept" : "*/*" },
425+ )
426+ file .writestr (meta ["filename" ], content )
419427
420428 return file_path
421429
You can’t perform that action at this time.
0 commit comments