miguelpruivo / flutter_file_picker

File picker plugin for Flutter, compatible with mobile (iOS & Android), Web, Desktop (Mac, Linux, Windows) platforms with Flutter Go support.
MIT License
1.33k stars 663 forks source link

saveFile() incomplete documentation #1524

Open timoxd7 opened 4 months ago

timoxd7 commented 4 months ago

Describe the bug On iOS, the saveFile method returns a String. The file then needs to be saved to the path described by this string. The "bytes" parameter has no effect. On Android however, the Data is given by the "bytes" parameter and this given data is saved instead.

Platform

Platform OS version iOS 17.5 Android ?

How are you picking?

outputFile = await FilePicker.platform.saveFile(
  dialogTitle: 'Please select an output file:',
  fileName: 'log.txt',
  type: FileType.any,
  bytes: currentLogBytes,
);

if (Platform.isIOS) File(outputFile).write(currentLogBytes);

Details to reproduce the issue Use Code above.

Flutter Version details [✓] Flutter (Channel stable, 3.22.1, on macOS 14.5 23F79 darwin-arm64, locale de-DE) • Flutter version 3.22.1 on channel stable at /Users/timo/sdk/flutter • Upstream repository https://github.com/flutter/flutter.git • Framework revision a14f74ff3a (13 days ago), 2024-05-22 11:08:21 -0500 • Engine revision 55eae6864b • Dart version 3.4.1 • DevTools version 2.34.3

Additional context file_picker 8.0.3

navaronbracke commented 4 months ago

I think this issue points to a bit of the API that can definitely improve. At the very least, we could do the saving of the file on iOS for you.

kaciula commented 4 weeks ago

This also happens for MacOS and Windows. You need to save the file once you get the output path.