-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Add support for download
function in web
#2230
base: main
Are you sure you want to change the base?
Conversation
download
function in web
This looks interesting, thanks! I read about We will need some tests and and likely an example. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably missing some error handling.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please write up a general idea of what behavior/standard it follows.
By further examining the web request, I realized that we use The problem of high memory is solved. thank you for checking again |
download
function in webdownload
function in web
Code Coverage Report: Only Changed Files listed
Minimum allowed coverage is |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still need some tests and examples here... 🛎️
Could you move on with the new structure of the code and add tests? |
# Conflicts: # dio/lib/src/adapters/browser_adapter.dart # dio/lib/src/dio/dio_for_browser.dart
changes are applied. thank you for checking again |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tests are still lacking.
changes are applied. thank you for checking again |
Please add tests. |
I tried to add the test, but I get the following error PS C:\Users\aaa\bbb\dio\plugins\web_adapter> flutter test
Error on line 10, column 3 of dart_test.yaml: Unknown platform "chrome".
╷
10 │ chrome:
│ ^^^^^^
╵ or PS C:\Users\aaa\bbb\dio\plugins\web_adapter\test> flutter test .\browser_test.dart
Changing current working directory to: C:\Users\aaa\bbb\dio\plugins\web_adapter
Error on line 10, column 3 of dart_test.yaml: Unknown platform "chrome".
╷
10 │ chrome:
│ ^^^^^^
╵ And I commented the contents of the "dart_test.yaml" file and run the tests again PS C:\Users\aaa\bbb\dio\plugins\web_adapter> flutter test
No tests ran.
No tests were found. or PS C:\Users\aaa\bbb\dio\plugins\web_adapter\test> flutter test .\browser_test.dart
Changing current working directory to: C:\Users\aaa\bbb\dio\plugins\web_adapter
No tests ran.
No tests were found. |
Try to set up the test like the GitHub workflow of this library. |
…orBrowser # Conflicts: # plugins/web_adapter/lib/src/adapter.dart # plugins/web_adapter/lib/src/dio_impl.dart
Test added |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What will the result be after downloaded? Could you demonstrate how it works?
EDIT: Please also add an example somewhere in our examples so everyone can run and see how it works.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added an example in example_flutter_app
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To test on the local web, make sure CORS is disabled.
and use local dio
and dio_web_adapter
in example_flutter_app pubspec
dependency_overrides:
dio_web_adapter:
path: ...\dio\plugins\web_adapter
dio:
path: ...\dio\dio
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why CORS is required?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To download a file from an online server to a local server, the browser gives a CORS error. This has nothing to do with Dio. I said this for testing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmmm, how about a local server to scope with the minimal functionality instead of an outer source?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you mean to put a file locally? If we do this, the download display will be very fast and the download percentage will not be clearly visible.
Are you sure about this? This is just an example to demonstrate a feature 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A demo would not require displaying the progress, correct? The file could be as small as possible too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think there are some examples for pure Dart
dio.download( |
Just need to run it on the web.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
New Pull Request Checklist
main
branch to avoid conflicts (via merge from master or rebase)CHANGELOG.md
in the corresponding packageAdditional context and info
In this PR, download support was added to dio with the help of
Blob
files.Note: There is no need to send
savePath
on the web and it can be empty.