Skip to content
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

Added withReadStream option to load a file in chunks (useful for large files which don't fit in RAM) #502

Merged
merged 2 commits into from Nov 20, 2020

Conversation

redsolver
Copy link
Contributor

Should work with Flutter Web and IO. Also see #465
Can for example be used with a multipart file upload.

Copy link
Owner

@miguelpruivo miguelpruivo left a comment

Choose a reason for hiding this comment

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

Thank you, this may come in handy for some. I left you some review comments.

lib/src/file_picker_io.dart Outdated Show resolved Hide resolved
lib/src/file_picker_io.dart Outdated Show resolved Hide resolved
lib/src/file_picker_web.dart Outdated Show resolved Hide resolved
@miguelpruivo miguelpruivo merged commit 894059f into miguelpruivo:master Nov 20, 2020
@miguelpruivo
Copy link
Owner

Thank you.

@redsolver redsolver deleted the read-file-as-stream branch December 1, 2020 18:02
@miguelpruivo
Copy link
Owner

@redsolver mind to provide an example on how do you create a File instance by using this approach? Thank you!

@redsolver
Copy link
Contributor Author

@miguelpruivo

The withReadStream option is not meant to be used to create a File instance. Instead it directly returns a Stream<List<int>>, similar to the openRead() method used by a File instance: https://api.dart.dev/stable/2.13.4/dart-io/File/openRead.html

The added benefit of withReadStream is that it works on both dart:io and dart:html with the same API.

@miguelpruivo
Copy link
Owner

@redsolver that's correct. What would be a good use case for it other than just uploading multipart file?

@redsolver
Copy link
Contributor Author

@miguelpruivo Uploading large files, encrypting or decrypting large files or just processing large files like importing a database, text file or JSON.

@miguelpruivo
Copy link
Owner

@redsolver did you manage to find a way to map it to a File instance?

@redsolver
Copy link
Contributor Author

@miguelpruivo I don't know why someone would want to do that?

@miguelpruivo
Copy link
Owner

@redsolver because I had someone asking me an example for that and couldn't find a way to. 😄 Maybe you want to help me out over here.

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.

None yet

2 participants