Skip to content

[3.x] Check status code when downloading file #816

@Olegt0rr

Description

@Olegt0rr

Similar to #799, but related to 3.x.
Don't forget to read @Tishka17's suggestions in the parent issue.

async def stream_content(
self, url: str, timeout: int, chunk_size: int
) -> AsyncGenerator[bytes, None]:
session = await self.create_session()
async with session.get(url, timeout=timeout) as resp:
async for chunk in resp.content.iter_chunked(chunk_size):
yield chunk

Metadata

Metadata

Assignees

No one assigned

    Labels

    3.xIssue or PR for stable 3.x versionbugSomething is wrong with the framework

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions