in ees_microsoft_teams/microsoft_teams_channels.py [0:0]
def get_attachment_content(self, document):
""" This function is used to fetch and extract the channel document from download URL
:param document: document that contains the details of channel document
Returns:
attachment_content: content of the attachment
"""
is_file = document.get("file", {})
# validate if file is exractable and not null
if is_file and type(is_file) != float:
mimetype = is_file.get("mimeType")
if mimetype not in constant.MIMETYPES:
download_url = document.get("@microsoft.graph.downloadUrl")
try:
attachment_content_response = requests.get(download_url)
if attachment_content_response:
attachment_content = None
try:
self.logger.info(f"Extracting the contents of {document.get('name')}.")
attachment_content = extract_api_response(attachment_content_response.content)
except TikaException as exception:
self.logger.exception(
f"Error while extracting contents of {document['name']} via Tika Parser. Error: "
f"{exception}")
return attachment_content
except RequestException as exception:
self.logger.exception(
f"Error while downloading the channel document from download URL: {download_url}. Error: "
f"{exception}")
raise