Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

support chunked upload in async file-like interfaces#3698

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
tsimoshka wants to merge7 commits intoencode:master
base:master
Choose a base branch
Loading
fromtsimoshka:chunked-async-file-upload

Conversation

@tsimoshka
Copy link

@tsimoshkatsimoshka commentedOct 28, 2025
edited
Loading

Summary

This PRresolves#1620 and implements chunked upload foranyio.open_file,trio.open_file andaiofiles.open_file when used ascontent= parameter forpost andput request. And implements support for multipart file upload for the same libraries. Most of the code for multipart file upload copied from my old stale PR#3339.

changes:

  • _compat.py file added to defineTypeIs andaclosing for the range of supported python versions
  • _types.AsyncReadableFile protocol was added along withis_async_readable_file type predicate function to detect and perform type narrowing for trio/asyncio/aiofiles async files
  • _types.FileContent was extended to include the._types.AsyncReadableFile protocol
  • _content.AsyncIteratorByteStream updated to useasync read methods for async files instead of looping over lines
  • _content.encode_content updated to attach content length header for_types.AsyncReadableFile type
  • _multipart.FileField updated to include async versions ofrender andrender_data
  • _multipart.MultipartStream updated with async version ofiter_data and__aiter__ method updated to use it
  • test_chunked_async_file_multipart andtest_chunked_async_file_content tests are added to test the new functionality
  • aiofiles andtypes-aiofiles added in requirements to test aiofiles (can be removed with test if aiofiles support is not desirable)

Checklist

  • I understand that this PR may be closed in case there was no previous discussion. (This doesn't apply to typos!)
  • I've added a test for each change that was introduced, and I tried as much as possible to make a single atomic change.
  • I've updated the documentation accordingly. (can update if PR is ok otherwise)

@tsimoshkatsimoshka changed the titlesupport chunked upload in async file-like interfacesWIP: support chunked upload in async file-like interfacesOct 28, 2025
@tsimoshkatsimoshka marked this pull request as draftOctober 28, 2025 13:15
@tsimoshkatsimoshka changed the titleWIP: support chunked upload in async file-like interfacessupport chunked upload in async file-like interfacesOct 28, 2025
@runtime_checkable doesn't work with trio async file since python3.12because hasattr in isinstance was replaced with`inspect.getattr_static()`
@tsimoshkatsimoshka marked this pull request as ready for reviewOctober 28, 2025 13:57
@tsimoshkatsimoshka marked this pull request as draftOctober 28, 2025 14:46
@tsimoshkatsimoshka marked this pull request as ready for reviewOctober 28, 2025 16:43
@tsimoshkatsimoshka marked this pull request as draftOctober 29, 2025 08:39
@tsimoshkatsimoshka marked this pull request as ready for reviewOctober 29, 2025 11:21
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Support async file types infiles = {} andcontent = ...

1 participant

@tsimoshka

[8]ページ先頭

©2009-2025 Movatter.jp