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.35k stars 675 forks source link

.save() will not write to file if file is larger than bytes provided #1569

Closed deathblade666 closed 3 months ago

deathblade666 commented 3 months ago

Before creating an issue, make sure that you are on the latest file_picker version and that there aren't already any similar opened inssues. Also, check if it isn't described on the Wiki, specially on Troubleshooting page.

Also, sometimes a simple flutter clean and flutter build again with latest file_picker version, may end up by fixing cached issues, so I encourage you to first do so.

Describe the bug using the bytes flag, when trying to update an existing file, it will not write to the file if the file size is more than the bytes you are trying to write (i.e. if content was removed from the file).

Platform

Platform OS version What version did it happen? latest beta at the time of writing

How are you picking?

List<int> list = utf8.encode(OpenFile.text);
            Uint8List bytes = Uint8List.fromList(list);
            await FilePicker.platform.saveFile(bytes: bytes);

(OpenFile is a texteditingcontroller)

Details to reproduce the issue See Decription

Error Log N/A

Screenshots and/or video If applicable, add screenshots or video to help explain your problem.

Flutter Version details Please, post the output of your flutter doctor -v, preferably, while running the issued device/simulator.

[✓] Flutter (Channel stable, 3.22.3, on Arch Linux 6.9.10-arch1-1, locale en_US.UTF-8)
    • Flutter version 3.22.3 on channel stable at /usr/bin/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision b0850beeb2 (3 weeks ago), 2024-07-16 21:43:41 -0700
    • Engine revision 235db911ba
    • Dart version 3.4.4
    • DevTools version 2.34.3

[✓] Android toolchain - develop for Android devices (Android SDK version 35.0.0)
    • Android SDK at ~/Android/Sdk
    • Platform android-34, build-tools 35.0.0
    • Java binary at: /opt/android-studio/jbr/bin/java
    • Java version OpenJDK Runtime Environment (build 17.0.11+0-17.0.11b1207.24-11852314)
    • All Android licenses accepted.

[✗] Chrome - develop for the web (Cannot find Chrome executable at google-chrome)
    ! Cannot find Chrome. Try setting CHROME_EXECUTABLE to a Chrome executable.

[✓] Linux toolchain - develop for Linux desktop
    • clang version 18.1.8
    • cmake version 3.30.0
    • ninja version 1.12.1
    • pkg-config version 2.1.1

[✓] Android Studio (version 2024.1)
    • Android Studio at /opt/android-studio
    • Flutter plugin version 80.0.2
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 17.0.11+0-17.0.11b1207.24-11852314)

[✓] Connected device (1 available)
    • Linux (desktop) • linux • linux-x64 • Arch Linux 6.9.10-arch1-1

[✓] Network resources
    • All expected network resources are available.

Additional context Add any other context about the problem here.

github-actions[bot] commented 3 months ago

This issue is stale because it has been open for 7 days with no activity.

miguelpruivo commented 3 months ago

The plugin is intended to use an integral copy of the original file and not ever modify the original file itself.