flutter_file_picker icon indicating copy to clipboard operation
flutter_file_picker copied to clipboard

`FilePicker.platform.getDirectoryPath()` seems to be moving the original directory to `tmp` directory [IOS]

Open hasanmhallak opened this issue 1 year ago • 54 comments

Describe the bug It seems like the FilePicker.platform.getDirectoryPath() will move the original directory instead of copying it to tmp/cache directory.

Platform

  • [ ] Android
  • [x] iOS
  • [ ] Web
  • [ ] Desktop

Platform OS version IOS 17.2

How are you picking?

final path = await FilePicker.platform.getDirectoryPath();
       print(path);

Details to reproduce the issue Try to use FilePicker.platform.getDirectoryPath() on any directory.

Error Log N/A

Screenshots and/or video

https://github.com/miguelpruivo/flutter_file_picker/assets/95232508/f0e1f64f-4b6c-47c8-8bbb-a3a7328bcda4

Flutter Version details

[✓] Flutter (Channel stable, 3.16.4, on macOS 13.5.2 22G91 darwin-arm64, locale
    en-EG)
[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.2)
[✓] Xcode - develop for iOS and macOS (Xcode 15.1)
[✓] Chrome - develop for the web
[!] Android Studio (version unknown)
    ✗ Unable to determine Android Studio version.
    ✗ Unable to find bundled Java version.
[✓] VS Code (version 1.85.2)
[✓] Connected device (3 available)
[✓] Network resources

Additional context When invoking FilePicker.platform.getDirectoryPath(); on Android, it successfully returns the actual path of any selected directory.

However, on iOS, due to the limitations you've outlined in your FAQ, one must copy the file or directory to a temporary directory for access.

An issue arises with FilePicker.platform.getDirectoryPath(); on iOS, where it moves the directory instead of copying it, contrary to the expected behavior. As a result, the user will permanently lose access to that directory.

hasanmhallak avatar Jan 29 '24 08:01 hasanmhallak

same here. any update on the issue?

Reyrey14-1 avatar Feb 02 '24 21:02 Reyrey14-1

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

github-actions[bot] avatar Feb 10 '24 01:02 github-actions[bot]

The FilePicker works fine on Android but on iOS it crashes my app with no permission to access "tmp", whether I want to pick an internal directory or an iCloud.

iOS 15.3.1

Error log after picking a folder "Test" in the internal directory structure:

“Test” couldn’t be moved because you don’t have permission to access “tmp”.
*** Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[__NSArrayM objectAtIndex:]: index 0 beyond bounds for empty array'
*** First throw call stack:
(0x1808e10fc 0x199131d64 0x1809ea564 0x1808770e4 0x104dd361c 0x1836ec2dc 0x18309a524 0x1835e2748 0x182f31f18 0x183144998 0x182f9b190 0x182fb5dd0 0x182e812e8 0x182e95a5c 0x182e95bc4 0x18466aa08 0x180553670 0x180561b70 0x180899d84 0x180853f5c 0x180867468 0x19c40b38c 0x18320a5d0 0x182f88f74 0x102efcb28 0x10434daa4)
libc++abi: terminating with uncaught exception of type NSException
* thread #1, queue = 'com.apple.main-thread', stop reason = signal SIGABRT
    frame #0: 0x00000001b7ecc964 libsystem_kernel.dylib`__pthread_kill + 8
libsystem_kernel.dylib`:
->  0x1b7ecc964 <+8>:  b.lo   0x1b7ecc984               ; <+40>
    0x1b7ecc968 <+12>: pacibsp 
    0x1b7ecc96c <+16>: stp    x29, x30, [sp, #-0x10]!
    0x1b7ecc970 <+20>: mov    x29, sp
Target 0: (Runner) stopped.
Lost connection to device.

Exited.

Why is it even trying to move the "Test" directory? I just picked it as a target to save a file into at a later step, nothing else...

ElHyperion avatar Feb 14 '24 12:02 ElHyperion

any updated here ? I met same issue :(

mrwill84 avatar Feb 16 '24 09:02 mrwill84

very frustrating this issue is seemingly ignored. this library is basically the only way to access files/folders with flutter

NomadicDeveloper22 avatar Feb 17 '24 23:02 NomadicDeveloper22

Same here, any solutions? @miguelpruivo

ryanhoo avatar Feb 18 '24 05:02 ryanhoo

I tested some older versions of this library and it seems to yield the same issue, perhaps there has been a breaking change in newer iOS versions?

ElHyperion avatar Feb 18 '24 09:02 ElHyperion

I tested some older versions of this library and it seems to yield the same issue, perhaps there has been a breaking change in newer iOS versions?

I'm trying on ios 16 (physical device) and experiencing it

NomadicDeveloper22 avatar Feb 18 '24 22:02 NomadicDeveloper22

Same here, we need a fix please.

logan-oss avatar Feb 21 '24 11:02 logan-oss

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

github-actions[bot] avatar Feb 29 '24 01:02 github-actions[bot]

Bump

mateusz-bak avatar Mar 08 '24 00:03 mateusz-bak

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

github-actions[bot] avatar Mar 15 '24 01:03 github-actions[bot]

Bumped

mateusz-bak avatar Mar 15 '24 06:03 mateusz-bak

What's the status of this? Haven't experienced any issue in the meantime. Does this only happen on iOS 17.0? I'm not sure if I correctly understood the issue, it doesn't pick the path, is that it?

miguelpruivo avatar Mar 20 '24 12:03 miguelpruivo

@miguelpruivo The issue is present on iOS 15 and newer, not Android. Picking any directory results in the missing permissions for "tmp" error message for me (as seen in my error log above), not sure about what others get.

ElHyperion avatar Mar 20 '24 12:03 ElHyperion

I guess I'll have to try to replicate in order to fix it or some issue a PR.

Any reproducible example or steps to?

miguelpruivo avatar Mar 20 '24 12:03 miguelpruivo

Simply calling FilePicker.platform.getDirectoryPath(); and picking -any- directory, whether internal or on iCloud, was enough for me. The issue happened every time.

ElHyperion avatar Mar 20 '24 12:03 ElHyperion

For me on real devices the issue is reproducible. Works fine for simulator.

we-prajapati-c001 avatar Mar 20 '24 12:03 we-prajapati-c001

Simply calling FilePicker.platform.getDirectoryPath(); and picking -any- directory, whether internal or on iCloud, was enough for me. The issue happened every time.

But what is exactly the issue?

miguelpruivo avatar Mar 20 '24 16:03 miguelpruivo

@miguelpruivo selecting the directory crashes the app and throws the error that I pasted above.

ElHyperion avatar Mar 20 '24 18:03 ElHyperion

hey @miguelpruivo, sorry for the late replay.

When invoking FilePicker.platform.getDirectoryPath(); on Android, it successfully returns the actual path of any selected directory.

However, on iOS, due to the limitations you've outlined in your FAQ, one must copy the file or directory to a temporary directory for access.

An issue arises with FilePicker.platform.getDirectoryPath(); on iOS, where it moves the directory instead of copying it, contrary to the expected behavior. As a result, the user will permanently lose access to that directory.

This concern is addressed in the issue that I've opened.

Edit:

This making me wonder if we was able to move the original folder why we are copying the file in first place?

hasanmhallak avatar Mar 20 '24 19:03 hasanmhallak

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

github-actions[bot] avatar Mar 29 '24 01:03 github-actions[bot]

Bump

mateusz-bak avatar Mar 29 '24 08:03 mateusz-bak

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

github-actions[bot] avatar Apr 06 '24 01:04 github-actions[bot]

Bump

mateusz-bak avatar Apr 06 '24 02:04 mateusz-bak

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

github-actions[bot] avatar Apr 14 '24 02:04 github-actions[bot]

Bump

mateusz-bak avatar Apr 14 '24 04:04 mateusz-bak

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

github-actions[bot] avatar Apr 23 '24 01:04 github-actions[bot]

bump

we-prajapati-c001 avatar Apr 23 '24 04:04 we-prajapati-c001

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

github-actions[bot] avatar May 08 '24 01:05 github-actions[bot]