feat(web_adapter): implement download method for web platforms#2485
Open
meylis1998 wants to merge 2 commits intocfug:mainfrom
Open
feat(web_adapter): implement download method for web platforms#2485meylis1998 wants to merge 2 commits intocfug:mainfrom
meylis1998 wants to merge 2 commits intocfug:mainfrom
Conversation
Implement the download() method for web platforms using the Blob API instead of throwing UnsupportedError. This allows users to download files in web browsers using the same API as native platforms. The implementation: - Fetches file content as bytes with progress tracking support - Creates a Blob from response bytes - Triggers browser's native download dialog via anchor element - Uses savePath as suggested filename (extracts filename from path) - Supports both String and callback-based savePath Limitations on web (documented in code): - deleteOnError and fileAccessMode parameters are ignored - Entire file is loaded into memory (not suitable for very large files) - Actual save location is determined by browser, not savePath Fixes cfug#2408
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
download()method for web platforms using the Blob API instead of throwingUnsupportedErrorDetails
This PR enables file downloads in web browsers using the same
dio.download()API that works on native platforms.How it works:
savePathas the suggested filename (extracts filename portion from paths)Supported features on web:
onReceiveProgresscancelTokensavePathsavePathLimitations (documented in code):
deleteOnErrorparameter is ignored (not applicable on web)fileAccessModeparameter is ignored (not applicable on web)savePathUsage example:
Fixes #2408
Test plan
dart analyzepasses with no issues