file_saver 0.6.0
file_saver: ^0.6.0 copied to clipboard
Save files from bytes, paths, streams, and URLs across Android, iOS, Web, Windows, macOS, and Linux.
Changelog #
All notable changes to this project will be documented in this file.
0.6.0 #
- Added
saveToDownloadsfor writing into the shared Downloads folder without a dialog, with an optionalsubfolder. Android uses MediaStore (no permission on Android 10+); macOS, Windows and Linux write to the user's Downloads directory; web triggers a browser download; iOS throwsUnsupportedError. - Desktop saves now honour a
sourcePath, sosaveToDownloads(filePath:)copies without loading the file into memory.
0.5.0 #
- Breaking: replaced the
diodependency withpackage:http.dioClientis nowhttpClient(http.Client?) onsaveFile,saveAsandsaveLinkAsStream.transformDioResponseis removed; responses are always bytes. Fetch and transform yourself, then passbytes:.LinkDetails.responseTypeis removed.LinkDetails.uriexposes the link withqueryParametersmerged.- HTTP 4xx/5xx responses now throw
http.ClientExceptioninstead of writing the error body to disk. - Fixes #102.
- macOS: sandbox failures now say which entitlement is missing —
com.apple.security.files.downloads.read-writewhen the Downloads write fails,com.apple.security.network.clientwhen the download fails.- Fixes #143.
- Migrated Android to built-in Kotlin / AGP 9 compatibility. Requires Flutter 3.44+.
- Added
initialDirectorytosaveAs,saveAsStreamandsaveLinkAsStreamso the save dialog can open in a chosen folder (macOS, Windows, iOS, Android). - Added
saveToGalleryfor saving images and videos to the photo library — MediaStore on Android, Photos on iOS — with an optionalalbum.- Fixes #64.
- Added
dialogTitletosaveAs,saveAsStreamandsaveLinkAsStream(macOS, Windows).- Fixes #146.
- Windows
saveAsconvertsinitialDirectoryanddialogTitlefrom UTF-8 withMultiByteToWideChar. - Breaking: Android
saveFilenow throws aPlatformExceptionon failure instead of returning an error message as the path. - Threading and streaming hardening across platforms:
- Android: file copies run on a supervised IO scope and reply exactly once;
saveAssurvives rotation while the picker is open, fails cleanly when the Activity is destroyed or no app can show the picker, and rejects a secondsaveAswhile one is open instead of silently dropping the first. Error details no longer carry aThrowablethe channel codec cannot encode. - iOS: temp-file writes and copies run off the main thread, payloads are no longer copied into
[UInt8], the picker is presented on the top-most controller, and a secondsaveAswhile one is open is rejected. - macOS: copies stream in 1 MiB chunks off the main thread and failures throw instead of returning
"Failed to save file"as the path. - Windows: the dialog is owned by the app window, uses heap buffers instead of a 1 MiB stack array and fixed
MAX_PATHstatics (a long file name aborted the process), builds the filter correctly, converts names and paths from UTF-8, and reports dialog errors instead of treating them as cancel. - Web: cancelling the File System Access picker resolves to
nulllike other platforms; a failed stream is aborted without masking the original error. saveAsStreamdeletes its temp file when the stream fails.
- Android: file copies run on a supervised IO scope and reply exactly once;
- Platform channels are now generated with Pigeon from
pigeons/messages.dart(regenerate withtool/pigeon.sh), so argument mismatches fail at compile time. WindowssaveAsreturns the path as a UTF-8 string. macOS deployment target is now 10.15. - Removed the unused
FileUtils.ktand the duplicatemacos/Classessources — macOS builds frommacos/file_saver/Sourcesfor both CocoaPods and Swift Package Manager. - Documented macOS entitlement file naming and Windows SDK requirements.
0.4.0 #
- Added Swift Package Manager support for iOS and macOS.
- Split native file helpers behind conditional imports to keep Web/Wasm analysis away from
dart:ioand platform-specific path provider implementations. - Hardened Android file name handling against path traversal.
- Moved Android
saveAsfile writes off the main thread and avoids resolving SAF document paths after saving. - Added web
saveAssupport using the existing browser download flow. - Added
downloadLinkfor web browser handoff and Android DownloadManager downloads without loading bytes into Dart memory. - Added
saveAsStreamfor native streamed writes via a temporary file. - Added
saveLinkAsStreamfor authenticated streamed URL downloads with request headers where supported. - Added native file-path copying for iOS, macOS, and Windows
saveAsto avoid loading filePath inputs into memory. - Made
saveAsfileExtensionoptional. - Fixed macOS
saveAscancellation so the platform call always completes. - Added Windows invalid file name validation for
saveAs. - Updated Android Gradle, Kotlin, JVM, and SDK settings for current Flutter support.
0.3.1 #
- Added
includeExtensionboolean parameter to control whether file extension should be included in the saved filename - Renamed parameter from
exttofileExtensionfor better clarity and consistency - Added new MIME types: AVIF, HEIC, HEIF, Markdown, SQL, SVG, WebM, WebP, XML, YAML
- Bug fixes and performance improvements
- Updated dependencies to latest compatible versions
- Enhanced platform compatibility and stability
0.3.0 #
- Fixed and added
saveAsfor windows
0.2.14 #
0.2.13 #
- Merge PR #115 for wasm build
- Added 3 MP4 mime types for better compatibility with the MP4 files
0.2.10 #
- Moved from
httptodiofor better control over the headers and other options - LinkDetails has more options such as
method&body
here is the example of how to use the LinkDetailsLinkDetails( link: "www.example.com/file.extention", headers: /// Your headers here, method: /// Your method here (GET, POST, PUT, DELETE, PATCH), body: /// Request body here ), - Both
saveFileandsaveAsmethods now have thedioClient&transformDioResponseas a parameter, so you can pass your own dio client to the method and it will use that client to download the file & you can also pass thetransformDioResponseto transform the response as per your requirement.\await FileSaver.instance.saveFile( name: "FileName", link: "www.example.com/file.extention", filePath: "pathOfFile", file: File(), bytes: bytes, ext: "extention", mimeType: MimeType.pdf, dioClient: Dio(), transformDioResponse: (response) { return response.data; }); - Fixed (GitHub issue #95)
- Fixed (GitHub issue #92)
0.2.9 #
0.2.8 #
- Moving saveAs() support for macOS to production.
0.2.6 #
- Merged ([PR70])(https://github.com/incrediblezayed/file_saver/pull/70), resolving the issue ([#42])(https://github.com/incrediblezayed/file_saver/issues/42)
0.2.5 #
- Added apng mime type
- Added custom mimetype
So basically if you have a custom mimetype and it does not exists in the given enum, you can add your own mimeType using the field \
String? customMimeType,
and you will have to set the mimetype to custom and call the method like
await FileSaver.instance.saveFile(
name: "FileName",
link: "www.example.com/file.extention",
filePath: "pathOfFile",
file: File(),
bytes: bytes,
ext: "extention",
customMimeType: 'YourCustomType',
mimeType: MimeType.custom);
- Fixed repeated extension when using saveAs with MimeType.other on iOS (GitHub issue #65)
0.2.4 #
- Bug Fix -> Link Details not available publically
0.2.3 #
- Replaced the
String? linkwithLinkDetails? linkin order to add headers with the link for downloading file - Fixed (GitHub issue #59)
0.2.2 #
- Implemented the web platform without method channel, using the conditional imports.
0.2.1 #
- Fixed a bug in web (git issue #57)
- Updated dart version constraints
- Updated MimeType enum to enhanced enum (from dart 2.17.0) and removed method getMimetype(), if you want to get the mimeType from the enum you can directly write
MimeType.pdf.type
And if you want the formatted name of the given type, you can get it by
MimeType.pdf.name
0.2.0 #
-
Fixed several issues from github
-
Feature Added a parameter link for saving file directly through network
-
Feature Added filePath if you have the filepath, no need to get the bytes of the file, you can directly pass the path in filePath parameter and the file_saver will do the rest
-
Feature Added file parameter to direct save the file from File object
-
Regardless of all the new options for saving files, bytes parameter is still there and you can still use it but, All the parameters are optional now so you have to use atleast one of these parameter (link, filePath, file, bytes)
-
Changed all the parameters to named instead of positional so now instead of
await FileSaver.instance.saveFile("FileName", bytes, "extension", mimeType: mimeType); await FileSaver.instance.saveAs("File", bytes, "extension", type);you will have to use
await FileSaver.instance.saveFile( name: "FileName", link: "www.example.com/file.extention", filePath: "pathOfFile", file: File(), bytes: bytes, ext: "extention", mimeType: type); await FileSaver.instance.saveFile( name: "FileName", link: "www.example.com/file.extention", filePath: "pathOfFile", file: File(), bytes: bytes, ext: "extention", mimeType: type);link, filePath, bytes & file are all optional parameters but any one of these parameter is required and thus you can use any one of these parameter as per your requirement #
-
Changed the MimeType enum values to lower case (as per dart's naming conventions)
-
Upgraded everything to latest versions (gradle tools = 7.4.2, kotlin=1.8.0)
0.1.1 #
- Updated the pub to the latest commit, fixing the issues with flutter 3.
0.1.0 #
- Fixed the incomplete path in saveFile method (GitHub issue #16)
- Fixed some crashes in some folders on saveAs method with the help of this answer
- Fixed application crash issue reply already submitted with the help of this suggestion (GitHub issue #14)
- Fixed Wrong or missing file extension when calling saveAs() (GitHub issue #20)
0.0.12 #
- Fixed Path Provider version
0.0.11 #
- Updated Readme
- Upgraded Path Provider
- Updated Kotlin version to 1.16.10
0.0.10 #
- Updated Readme
- Due to security reasons, I'm not able to save the files to downloads folder in android, if anyone has any idea that would work on Android 11 so please connect.
0.0.9 #
- Android Permission Bug Fixed
- Other bugs fixes
0.0.8 #
- Minor Bug Fixes
- Updated Readme
0.0.7 #
- Added Save as method for Android and iOS, more coming soon
- Bug fixes & Suggestions (Reported on Github)
0.0.6 #
- Added More File Types
0.0.5 #
- Minor Bug Fixes
0.0.4 #
- saveFile method returns the path where the file is saved.
0.0.3 #
- Minor Bug Fixes
0.0.2 #
- Updated Guide
0.0.1 #
- File Saver for all platforms