2
0
mirror of https://github.com/pyrogram/pyrogram synced 2025-08-29 13:27:47 +00:00

Respect file_name if file passed is a file object (#912)

Fixes #911
This commit is contained in:
blank X 2022-02-26 10:13:08 +00:00 committed by GitHub
parent bf233e3b5b
commit e0eccfa8fb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 8 additions and 8 deletions

View File

@ -201,7 +201,7 @@ class SendAnimation(Scaffold):
thumb = await self.save_file(thumb) thumb = await self.save_file(thumb)
file = await self.save_file(animation, progress=progress, progress_args=progress_args) file = await self.save_file(animation, progress=progress, progress_args=progress_args)
media = raw.types.InputMediaUploadedDocument( media = raw.types.InputMediaUploadedDocument(
mime_type=self.guess_mime_type(animation.name) or "video/mp4", mime_type=self.guess_mime_type(file_name or animation.name) or "video/mp4",
file=file, file=file,
thumb=thumb, thumb=thumb,
attributes=[ attributes=[
@ -211,7 +211,7 @@ class SendAnimation(Scaffold):
w=width, w=width,
h=height h=height
), ),
raw.types.DocumentAttributeFilename(file_name=animation.name), raw.types.DocumentAttributeFilename(file_name=file_name or animation.name),
raw.types.DocumentAttributeAnimated() raw.types.DocumentAttributeAnimated()
] ]
) )

View File

@ -197,7 +197,7 @@ class SendAudio(Scaffold):
thumb = await self.save_file(thumb) thumb = await self.save_file(thumb)
file = await self.save_file(audio, progress=progress, progress_args=progress_args) file = await self.save_file(audio, progress=progress, progress_args=progress_args)
media = raw.types.InputMediaUploadedDocument( media = raw.types.InputMediaUploadedDocument(
mime_type=self.guess_mime_type(audio.name) or "audio/mpeg", mime_type=self.guess_mime_type(file_name or audio.name) or "audio/mpeg",
file=file, file=file,
thumb=thumb, thumb=thumb,
attributes=[ attributes=[
@ -206,7 +206,7 @@ class SendAudio(Scaffold):
performer=performer, performer=performer,
title=title title=title
), ),
raw.types.DocumentAttributeFilename(file_name=audio.name) raw.types.DocumentAttributeFilename(file_name=file_name or audio.name)
] ]
) )

View File

@ -180,11 +180,11 @@ class SendDocument(Scaffold):
thumb = await self.save_file(thumb) thumb = await self.save_file(thumb)
file = await self.save_file(document, progress=progress, progress_args=progress_args) file = await self.save_file(document, progress=progress, progress_args=progress_args)
media = raw.types.InputMediaUploadedDocument( media = raw.types.InputMediaUploadedDocument(
mime_type=self.guess_mime_type(document.name) or "application/zip", mime_type=self.guess_mime_type(file_name or document.name) or "application/zip",
file=file, file=file,
thumb=thumb, thumb=thumb,
attributes=[ attributes=[
raw.types.DocumentAttributeFilename(file_name=document.name) raw.types.DocumentAttributeFilename(file_name=file_name or document.name)
] ]
) )

View File

@ -207,7 +207,7 @@ class SendVideo(Scaffold):
thumb = await self.save_file(thumb) thumb = await self.save_file(thumb)
file = await self.save_file(video, progress=progress, progress_args=progress_args) file = await self.save_file(video, progress=progress, progress_args=progress_args)
media = raw.types.InputMediaUploadedDocument( media = raw.types.InputMediaUploadedDocument(
mime_type=self.guess_mime_type(video.name) or "video/mp4", mime_type=self.guess_mime_type(file_name or video.name) or "video/mp4",
file=file, file=file,
ttl_seconds=ttl_seconds, ttl_seconds=ttl_seconds,
thumb=thumb, thumb=thumb,
@ -218,7 +218,7 @@ class SendVideo(Scaffold):
w=width, w=width,
h=height h=height
), ),
raw.types.DocumentAttributeFilename(file_name=video.name) raw.types.DocumentAttributeFilename(file_name=file_name or video.name)
] ]
) )