-
Notifications
You must be signed in to change notification settings - Fork 1
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
v1.4.0 #16
Closed
thiagocarvalhodev
wants to merge
45
commits into
main
from
PE-3699-uploads-large-files-for-public-drives
Closed
v1.4.0 #16
Changes from 12 commits
Commits
Show all changes
45 commits
Select commit
Hold shift + click to select a range
f571796
Implement save stream IO (no-firefox)
elliotsayes 6f43f7b
Add support for aborting on failed verification
elliotsayes dedfa0e
Release writer lock
elliotsayes 72957fc
Remove close on writer
elliotsayes 52a213c
Implement download using StreamSaver.js
elliotsayes 19e6be3
Fix improper closing
elliotsayes 6b49c83
Wait for readyFuture again
elliotsayes 5ce5a5a
Switch to DartIOFileSaver for saveStream:
elliotsayes 870cdae
Add code to find empty files
elliotsayes d844bfc
ArDriveDownloader uses same download filename...
elliotsayes cf46631
Better handling of no content-type
elliotsayes b3a491b
Fix basename bug (oops)
elliotsayes 41e1ad7
Fix extension ..
elliotsayes 9a8d652
Fix wrong arg order (oops)
elliotsayes 21f5a45
Change saveFileStream API to completer
elliotsayes 03482c6
Better abort logic
elliotsayes 3698836
Implement save status stream
elliotsayes 2ae9de2
Rename flag to saveResult
elliotsayes 8a82370
Remove commented code
elliotsayes d2f71fa
More descriptive exceptions
elliotsayes 2366575
Move empty file finder to path_utils
elliotsayes 9de8d78
Make "test" var name more explicit
elliotsayes 229147e
Clearer name: emptyFile => nonexistentFile
elliotsayes 2631a98
variable name `extension` => `fileExtension`
elliotsayes dde4cd0
More clear exit condition on while loop
elliotsayes 37294df
Add TODO to catch near-infinite loops
elliotsayes 46f2c11
Work around weird mime behavior?
elliotsayes 5df5b19
Fixed comparison to use lowercase
elliotsayes abd6e86
feat(save files on app dir)
thiagocarvalhodev 295b3ae
Update fvm_config.json
thiagocarvalhodev a07b81c
Update pubspec.yaml
thiagocarvalhodev 49ef040
Update pubspec.yaml
thiagocarvalhodev 136d27a
Update web_io.dart
thiagocarvalhodev 3a60e46
feat(IOFolder)
thiagocarvalhodev 080f74c
feat(uploader)
thiagocarvalhodev 3ca5ffd
Update io_folder_test.dart
thiagocarvalhodev 9f0c97d
feat(iofolder)
thiagocarvalhodev 2359255
upgrade deps
thiagocarvalhodev daef5c6
remove folder tree generation of files
thiagocarvalhodev 7bd6e71
fix lint rules
thiagocarvalhodev 599780a
Merge pull request #10 from elliotsayes/write-file-stream
thiagocarvalhodev 3ce83fd
Merge branch 'dev' into PE-3699-uploads-large-files-for-public-drives
thiagocarvalhodev 5998dfd
add stream saver
thiagocarvalhodev b42e3dc
Update web_io.dart
thiagocarvalhodev 8c6ac43
Update web_io.dart
thiagocarvalhodev File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
{ | ||
"flutterSdkVersion": "3.10.0", | ||
"flutterSdkVersion": "3.10.2", | ||
"flavors": {} | ||
} |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -64,9 +64,9 @@ class MobileIO implements ArDriveIO { | |
} | ||
|
||
@override | ||
Future<void> saveFile(IOFile file) async { | ||
Future<void> saveFile(IOFile file, [bool saveOnAppDirectory = false]) async { | ||
try { | ||
await _fileSaver.save(file); | ||
await _fileSaver.save(file, saveOnAppDirectory: saveOnAppDirectory); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We can get rid of this try..catch because it's rethrowing and nothing else. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same comment for the method below. |
||
} catch (e) { | ||
rethrow; | ||
} | ||
|
@@ -78,12 +78,24 @@ class MobileIO implements ArDriveIO { | |
/// This implementation uses the `file_saver` package. | ||
/// | ||
/// Throws an `FileSystemPermissionDeniedException` when user deny access to storage | ||
/// | ||
/// `saveOnAppDirectory` is not supported on this implementation | ||
class MobileSelectableFolderFileSaver implements FileSaver { | ||
final DartIOFileSaver _dartIOFileSaver; | ||
|
||
MobileSelectableFolderFileSaver({DartIOFileSaver? dartIOFileSaver}) | ||
: _dartIOFileSaver = dartIOFileSaver ?? DartIOFileSaver(); | ||
|
||
@override | ||
Future<void> save(IOFile file) async { | ||
Future<void> save(IOFile file, {bool saveOnAppDirectory = false}) async { | ||
await requestPermissions(); | ||
await verifyPermissions(); | ||
|
||
if (saveOnAppDirectory) { | ||
await _dartIOFileSaver.save(file, saveOnAppDirectory: saveOnAppDirectory); | ||
return; | ||
} | ||
|
||
await file_saver.FileSaver.instance.saveAs( | ||
name: file.name, | ||
bytes: await file.readAsBytes(), | ||
|
@@ -98,7 +110,7 @@ class MobileSelectableFolderFileSaver implements FileSaver { | |
/// It will save on `getDefaultMobileDownloadDir()` | ||
class DartIOFileSaver implements FileSaver { | ||
@override | ||
Future<void> save(IOFile file) async { | ||
Future<void> save(IOFile file, {bool saveOnAppDirectory = false}) async { | ||
await requestPermissions(); | ||
await verifyPermissions(); | ||
|
||
|
@@ -111,13 +123,30 @@ class DartIOFileSaver implements FileSaver { | |
fileName += '.$fileExtension'; | ||
} | ||
|
||
if (saveOnAppDirectory) { | ||
await _saveOnAppDir(file, fileName); | ||
return; | ||
} | ||
|
||
await _saveOnDownloadsDir(file, fileName); | ||
} | ||
|
||
Future<void> _saveOnDownloadsDir(IOFile file, String fileName) async { | ||
/// platform_specific_path/Downloads/ | ||
final defaultDownloadDir = await getDefaultMobileDownloadDir(); | ||
|
||
final newFile = File(defaultDownloadDir + fileName); | ||
|
||
await newFile.writeAsBytes(await file.readAsBytes()); | ||
} | ||
|
||
Future<void> _saveOnAppDir(IOFile file, String fileName) async { | ||
final appDir = await getDefaultAppDir(); | ||
|
||
final newFile = File(appDir + fileName); | ||
|
||
await newFile.writeAsBytes(await file.readAsBytes()); | ||
} | ||
} | ||
|
||
/// Defines the API for saving `IOFile` on Storage | ||
|
@@ -130,5 +159,5 @@ abstract class FileSaver { | |
'The ${Platform.operatingSystem} platform is not supported'); | ||
} | ||
|
||
Future<void> save(IOFile file); | ||
Future<void> save(IOFile file, {bool saveOnAppDirectory = false}); | ||
} |
This file contains 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
This file contains 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
This file contains 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
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.
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.
can we get rid of this log?