【问题标题】:FileSystemException: Cannot retrieve length of file (OS Error: No such file or directory, errno = 2)FileSystemException:无法检索文件长度(操作系统错误:没有这样的文件或目录,errno = 2)
【发布时间】:2020-08-10 14:24:15
【问题描述】:

我正在使用file_picker: ^1.7.1 这个插件在android 中运行良好,但是在真实设备iOS 13.4.1 中使用时出现异常,在上传pdf 文件时出现FileSystemException。

错误日志
2020-04-29 15:56:04.991427+0530 Runner[4358:1416983] [VERBOSE-2:ui_dart_state.cc(157)] Unhandled Exception: FileSystemException: Cannot retrieve length of file, path = '/private/var/mobile/Containers/Data/Application/0C1997E5-5243-494E-85EA-830E3248CC97/tmp/com.vassar.bluis-Inbox/https:%2Ffoodlicensing.fssai.gov.in%2FREG%2FRG_ViewReceipt.aspx?ReqID=68198366.pdf' (OS Error: No such file or directory, errno = 2)

#0 _File.length. (dart:io/file_impl.dart:376:9)
#1 _rootRunUnary (dart:async/zone.dart:1134:38)
#2 _CustomZone.runUnary (dart:async/zone.dart:1031:19)
#3 _FutureListener.handleValue (dart:async/future_impl.dart:139:18)
#4 Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:680:45)

Flutter 版本详情

[✓] Flutter (Channel stable, v1.12.13+hotfix.9, on Mac OS X 10.15.4 19E287,
locale en-IN)
• Flutter version 1.12.13+hotfix.9 at /Users/teja/flutter_dev/flutter
• Framework revision f139b11009 (4 weeks ago), 2020-03-30 13:57:30 -0700
• Engine revision af51afceb8
• Dart version 2.7.2

[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
• Android SDK at /Users/teja/Library/Android/sdk
• Android NDK location not configured (optional; useful for native profiling
support)
• Platform android-29, build-tools 29.0.2
• Java binary at: /Applications/Android
Studio.app/Contents/jre/jdk/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build
1.8.0_202-release-1483-b49-5587405)
• All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 11.4.1)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Xcode 11.4.1, Build version 11E503a
• CocoaPods version 1.9.1

[✓] Android Studio (version 3.5)
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin version 42.1.1
• Dart plugin version 191.8593
• Java version OpenJDK Runtime Environment (build
1.8.0_202-release-1483-b49-5587405)

[✓] Connected device (1 available)
• Shahnawaz’s iphone • d59a055eb9bbddc9be958142d9c484e3c45bbf2f • ios • iOS
13.4.1

• No issues found

【问题讨论】:

  • 您是否在 Android 和 iOS 上都给予了尊重的许可?
  • 对于 android 它工作正常,我不确定 iOS 读取目录/文件的权限。@Ra
  • 你需要像我们在Manifest in Andorid案例中一样在iOS中进行权限输入
  • 是的,我已按要求给予许可@RavindraKushwaha
  • @MdShahnawaz 对此有何更新?

标签: flutter flutter-dependencies filepicker.io flutter-plugin


【解决方案1】:

Flutter file_picker 似乎存在问题。 更新它应该是一个很好的修复

由于iOS 13,您需要通过startAccessingSecurityScopedResource 请求访问您的应用沙箱外的文件,如果没有,您将看到lengthopen 问题,即使您确实有一个有效的文件路径。

您可以在here 中找到更多信息,这实际上也适用于文件。

【讨论】:

    猜你喜欢
    • 2020-05-13
    • 2022-08-18
    • 1970-01-01
    • 2020-01-13
    • 2020-02-15
    • 2022-01-16
    • 2022-12-16
    • 2018-03-28
    • 1970-01-01
    相关资源
    最近更新 更多