Skip to content

feat: add FileDownloadCrawler#2043

Open
Mantisus wants to merge 2 commits into
apify:masterfrom
Mantisus:file-downloaw-crawler
Open

feat: add FileDownloadCrawler#2043
Mantisus wants to merge 2 commits into
apify:masterfrom
Mantisus:file-downloaw-crawler

Conversation

@Mantisus

@Mantisus Mantisus commented Jul 8, 2026

Copy link
Copy Markdown
Collaborator

Description

  • Adds FileDownloadCrawler with support for streaming the response body in the request handler.

Issues

Testing

  • Added tests for FileDownloadCrawler

@Mantisus Mantisus self-assigned this Jul 8, 2026
@Mantisus Mantisus force-pushed the file-downloaw-crawler branch from 4669391 to db4ded0 Compare July 10, 2026 10:41
@Mantisus Mantisus marked this pull request as ready for review July 10, 2026 10:48
@Mantisus Mantisus requested review from Pijukatel and vdusek July 10, 2026 10:48

@Pijukatel Pijukatel left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For large files, it would be great to have something like https://pypi.org/project/smart-open/ , but our storages lacks interface to support such chunked uploads

Comment thread docs/guides/http_crawlers.mdx

@vdusek vdusek left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Otherwise it looks great

)

self._statistics.register_status_code(response.status_code)
context.request.state = RequestState.AFTER_NAV

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From Claude:

The streamed path never sets context.request.loaded_url, whereas the buffered crawl() path does (request.loaded_url = str(response.url)). As a result, in stream mode _check_url_after_redirects is effectively skipped (it's guarded by if loaded_url is not None), so off-domain redirects aren't filtered by the enqueue strategy, and context.request.loaded_url stays None for user code. It's a silent divergence between the two modes. The stream() API doesn't expose the final URL, so this may be hard to fix cleanly, but worth a note/follow-up.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's true. But we can't do that without updating the HTTP clients API. This will be fixed along with #874 when the clients are synchronized with Crawlee JS v4.

Comment thread docs/examples/code_examples/file_download_stream.py Outdated
Comment thread src/crawlee/crawlers/_file_download/_file_download_crawler.py Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement a FileDownload crawler

4 participants