Skip to content

Commit

Permalink
Fix when att mimetype has no guessed extension (#386)
Browse files Browse the repository at this point in the history
  • Loading branch information
sanjacob authored Sep 22, 2024
1 parent d6ecf79 commit 95ccdab
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion blackboard_sync/content/attachment.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ def __init__(self, attachment: BBAttachment, api_path: BBContentPath,

# Guess extension based on content
mime = attachment.mimeType or 'text/plain'
real_ext = mimetypes.guess_extension(mime, strict=False)
possible_ext = mimetypes.guess_all_extensions(mime, strict=False)

if name_ext in possible_ext:
self.filename = filename
else:
real_ext = possible_ext[0] if possible_ext else '.txt'
self.filename = filename + real_ext

self.stream = job.session.download(attachment_id=attachment.id,
Expand Down

0 comments on commit 95ccdab

Please sign in to comment.