Skip to content

Passing headers to URLInputfile and stream_content #1191

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
kinkyninja opened this issue Jun 18, 2023 · 1 comment · Fixed by #1197
Closed

Passing headers to URLInputfile and stream_content #1191

kinkyninja opened this issue Jun 18, 2023 · 1 comment · Fixed by #1197
Labels
3.x Issue or PR for stable 3.x version enhancement Make it better!

Comments

@kinkyninja
Copy link

Is your feature request related to a problem? Please describe.
I have an access to several protected url-links that require additional headers for downloading/get request.
My bot has to frequently upload large files from such links, mainly audio.
I can't upload these files with just audio = URLInputFile(URL) feature - because the site also need headers.

Idea is to upgrade URLInputfile function, so that it can be invoked with headers:
audio = URLInputFile(url, headers=headers)

Describe the solution you'd like
I made a quick patch for URLInputfile (added headers to arguments) and stream_content, so that you can make something like that
Screenshots attached.
Look at the screenshots.

Now my code works like this:
audio = URLInputFile(url, headers=headers)
await message.answer_audio(audio)

telegram-cloud-photo-size-2-5222076231141412094-y
telegram-cloud-photo-size-2-5222076231141412095-y

@kinkyninja
Copy link
Author

Thanks a lot!

Aqendo added a commit to Aqendo/aiogram that referenced this issue Jun 30, 2023
* parameter secret_token (aiogram#1173)

* Added secret token validation

* Fixed workflow data propagation (aiogram#1196)

* Coverage

* Added changelog

* aiogram#1191 Added possibility to pass custom headers to URLInputFile object (aiogram#1197)

---------

Co-authored-by: sheldy <85823514+sheldygg@users.noreply.github.com>
Co-authored-by: Alex Root Junior <jroot.junior@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3.x Issue or PR for stable 3.x version enhancement Make it better!
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants