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 658 forks source link

Temporary file could not be created. #997

Closed whedamd closed 1 week ago

whedamd commented 2 years ago

flutter: [MethodChannelFilePicker] Platform exception: PlatformException(file_picker_error, Temporary file could not be created, Error Domain=NSItemProviderErrorDomain Code=-1000 "Cannot load representation of type public.item" UserInfo={NSLocalizedDescription=Cannot load representation of type public.item}, null)

Platform: iOS

gabdsg commented 2 years ago

Same problem here

nobezawa commented 2 years ago

Have the same problem.

my version

file_picker:
    dependency: "direct main"
    description:
      name: file_picker
      url: "https://pub.dartlang.org"
    source: hosted
    version: "4.5.1"

Execution environment

iPhone Simulator: iPhone11
iOS: 15.2
miguelpruivo commented 2 years ago

Hi, how are you picking the files?

MyisCARRY commented 2 years ago

I am having the same problem. It only happens with one photo and the others work fine. I am using iOS simulator. Version 4.5.1. I am using this method: await FilePicker.platform.pickFiles(type: FileType.image);

Message:

Temporary file could not be created

Details:

Error Domain=NSItemProviderErrorDomain Code=-1000 "Cannot load representation of type public.item" UserInfo={NSLocalizedDescription=Cannot load representation of type public.item, NSUnderlyingError=0x600002ed33f0 {Error Domain=NSCocoaErrorDomain Code=4101 "Błąd komunikacji z aplikacją pomocniczą." UserInfo={NSUnderlyingError=0x600002e7cd80 {Error Domain=PHAssetExportRequestErrorDomain Code=0 "Nie można ukończyć tej operacji. (Błąd PHAssetExportRequestErrorDomain 0.)" UserInfo={NSLocalizedDescription=Nie można ukończyć tej operacji. (Błąd PHAssetExportRequestErrorDomain 0.), NSUnderlyingError=0x600002e7fd20 {Error Domain=PAMediaConversionServiceErrorDomain Code=2 "Nie można ukończyć tej operacji. (Błąd PAMediaConversionServiceErrorDomain 2.)" UserInfo=0x60000205b500 (not displayed)}}}}}}

Error from logs:

flutter: [MethodChannelFilePicker] Platform exception: PlatformException(file_picker_error, Temporary file could not be created, Error Domain=NSItemProviderErrorDomain Code=-1000 "Cannot load representation of type public.item" UserInfo={NSLocalizedDescription=Cannot load representation of type public.item, NSUnderlyingError=0x600002ed33f0 {Error Domain=NSCocoaErrorDomain Code=4101 "Błąd komunikacji z aplikacją pomocniczą." UserInfo={NSUnderlyingError=0x600002e7cd80 {Error Domain=PHAssetExportRequestErrorDomain Code=0 "Nie można ukończyć tej operacji. (Błąd PHAssetExportRequestErrorDomain 0.)" UserInfo={NSLocalizedDescription=Nie można ukończyć tej operacji. (Błąd PHAssetExportRequestErrorDomain 0.), NSUnderlyingError=0x600002e7fd20 {Error Domain=PAMediaConversionServiceErrorDomain Code=2 "Nie można ukończyć tej operacji. (Błąd PAMediaConversionServiceErrorDomain 2.)" UserInfo=0x60000205b500 (not displayed)}}}}}}, null)

gabdsg commented 2 years ago

For me this only happens in the iOS simulator, on a real iPhone it works fine. I only tried this on a mac M1...

miguelpruivo commented 2 years ago

You are probably trying with the pink flowers photo on the simulator — that's a known iOS simulator issue since iOS 14. You should "ignore it". 😄

neelansh-creatorstack commented 2 years ago

Same issue happening with me on a real device.

squaredx commented 2 years ago

I'm also experiencing this issue. I've been getting this issues on the Xcode simulator running Xcode 13.3.1, iOS 15.4.1, and package version 4.5.1. I have yet to test on a physical device yet.

Before this issue only occurred on the pink flowers picture in the simulator but now its happening with all the pictures. The error message I am getting is:

flutter: unhandled element metadata; Picture key: AssetBundlePictureKey(bundle: PlatformAssetBundle#dd967(), name: "assets/svg/manage-memories-blankstate.svg", colorFilter: null)
flutter: [MethodChannelFilePicker] Platform exception: PlatformException(file_picker_error, Temporary file could not be created, Error Domain=NSItemProviderErrorDomain Code=-1000 "Cannot load representation of type public.item" UserInfo={NSLocalizedDescription=Cannot load representation of type public.item}, null)
[VERBOSE-2:ui_dart_state.cc(209)] Unhandled Exception: PlatformException(file_picker_error, Temporary file could not be created, Error Domain=NSItemProviderErrorDomain Code=-1000 "Cannot load representation of type public.item" UserInfo={NSLocalizedDescription=Cannot load representation of type public.item}, null)

And the code I am using to call the file picker is:

final FilePickerResult? pickedFiles = await FilePicker.platform.pickFiles(
      type: FileType.media,
      allowMultiple: true,
      onFileLoading: (FilePickerStatus status) {
        print(status);
      },
    );

EDIT: I can't reproduce it on a physical device so it looks like a simulator issue (for me at least)

whedamd commented 2 years ago

Inside info.plist

NSCameraUsageDescription NSPhotoLibraryUsageDescription

Package: image_picker: ^0.8.4+11 Implementation: Uint8List? pickPhoto(ImageSource source) async { XFile file = await _picker.pickImage(source: source); if (file != null) { return Uint8List photo = await file.readAsBytes(); } return null; }

pinguluk commented 2 years ago

+1 for any picture on simulator

pinguluk commented 2 years ago

Update: it seems that if you exclude arm64 from Excluded Architectures from Target -> Runner, you'll get the error. If you remove it, it's working again. In my case I needed to exclude the arm64, because of another Pod that gets me another error (I've tried the solution to only exclude arm64 from the pods, but in my case it's only working if I exclude it from Runner), so I don't know what the best workaround or fix for this would be. image

yahu1031 commented 2 years ago

@miguelpruivo I tried with code block

  /// Uploads the file to the device.
  /// This function will return the list of files.
  static Future<Set<PlatformFile>> uploadFile(
          [FileType? fileType,
          bool? allowMultipleFiles,
          List<String>? extensions]) async =>
      (await FilePicker.platform.pickFiles(
              type: fileType ?? FileType.any,
              allowMultiple: allowMultipleFiles ?? false,
              allowedExtensions: extensions))
          ?.files
          .toSet() ??
      <PlatformFile>{};

Called it here

IconButton(
  icon: const Icon(
    TablerIcons.photo,
    color: Colors.black,
  ),
  onPressed: () async {
    try {
      // await controller!.stopCamera();
      Set<PlatformFile> _file =
          await AppService.uploadFile(FileType.image);
      if (_file.isNotEmpty) {
        bool _gotData = await AppService.getQRData(
          _scaffoldKey.currentContext!,
          _file.first.path,
        );
        if (_gotData) {
          await Navigator.pushReplacementNamed(
              context, PageRoutes.activatingAtSign);
        }
      } else {
        await controller!.startCamera(onScan);
        await showToast(
            'No image picked', _scaffoldKey.currentContext!, true);
      }
    } on Exception catch (e) {
      await controller!.stopCamera();
      qrLog.severe(e);
      await showToast('Failed to pick image',
          _scaffoldKey.currentContext!, true);
    }
  },
),

And the below is result.

https://user-images.githubusercontent.com/35523357/173558737-48d9b63f-66c9-4628-9f69-fdbdf19d8ae1.mp4

bawantha commented 2 years ago

Why this issue is closed?

conceptualben commented 2 years ago

You are probably trying with the pink flowers photo on the simulator — that's a known iOS simulator issue since iOS 14. You should "ignore it". 😄

I'm also experiencing this issue (Mac M1, iPhone Simulator with iOS 15.5). It looks like it was prematurely closed if this comment was the reason for closing this.

Looking at this similar package image_picker their readme states:

As a result of implementing PHPicker it becomes impossible to pick HEIC images on the iOS simulator in iOS 14+. This is a known issue. Please test this on a real device, or test with non-HEIC images until Apple solves this issue.

If file_picker's case is the same it would be useful to know it!

tiagocdr commented 2 years ago

Will there be a resolution for this ?

yahu1031 commented 2 years ago

May be this should be fixed from apple 😅

WaheedHussainHaans commented 2 years ago

I am not even picking that flower image but still getting that error on the Mac M1 chip. Any fixes ?

JaFa13 commented 2 years ago

This is still not working

phongkien commented 1 year ago

Seems to be random. On my MacBox pro, it is fined, on M1 (used to work but no longer working).

NabeelAbid1812 commented 1 year ago

I am not even picking that flower image but still getting that error on the Mac M1 chip. Any fixes ?

can I help you?

WaheedHussainHaans commented 1 year ago

@NabeelAbid1812 sure

anasboyka commented 1 year ago

same here still got the same problem... 19/12/2022

mac mini m1

donpui commented 1 year ago

I also recently had the same issue on iphonesimulator with media picking. However, I managed to make it work by changing Document Storage to "On My iPhone" and restarting app. Also try select not first media file, but any other.

Khodosov commented 11 months ago

Hello @miguelpruivo! I managed to reproduce this error on a real device. To do this, I tried to select a live photo from the gallery. At the same time, the photo was very old (taken on another iphone) and stored in iCloud. It seems the combination of iCloud and live-photo may be the key to the solution

aakarapetyan commented 8 months ago

also have the same problem. Any solution? flutter: [MethodChannelFilePicker] Platform exception: PlatformException(file_picker_error, Temporary file could not be created, Error Domain=NSItemProviderErrorDomain Code=-1000 "Cannot load representation of type public.item" UserInfo={NSLocalizedDescription=Cannot load representation of type public.item, NSUnderlyingError=0x28309be40 {Error Domain=NSCocoaErrorDomain Code=4097 "Couldn’t communicate with a helper application." UserInfo={NSUnderlyingError=0x28309a670 {Error Domain=NSCocoaErrorDomain Code=4097 "connection from pid 16965 on anonymousListener or serviceListener" UserInfo={NSDebugDescription=connection from pid 16965 on anonymousListener or serviceListener}}}}}, null) [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: PlatformException(file_picker_error, Temporary file could not be created, Error Domain=NSItemProviderErrorDomain Code=-1000 "Cannot load representation of type public.item" UserInfo={NSLocalizedDescription=Cannot load representation of type public.item, NSUnderlyingError=0x28309be40 {Error Domain=NSCocoaErrorDomain Code=4097 "Couldn’t communicate with a helper application." UserInfo={NSUnderlyingError=0x28309a670 {Error Domain=NSCocoaErrorDomain Code=4097 "connection from pid 16965 on anonymousListener or serviceListener" UserInfo={NSDebugDescription=connection from pid 16965 on anonymousListener or serviceListener}}}}}, null)

0 StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:651:7)

1 MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:322:18)

#2 MethodChannel.invokeListMethod (package:flutter/src/services/platform_channel.dart:508:35) #3 FilePickerIO._getPath (package:file_picker/src/file_picker_io.dart:92:33)
SmueezApex commented 6 months ago

Facing the same issue as well. need t fix this ASAP

ghost commented 6 months ago

I am facing this issue on real ios device.

gonciuu commented 4 months ago

Also facing the same issue on real iphone device

joachimbulow commented 1 month ago

We are also facing this issue in semi large scale on production devices

Xarvis commented 1 month ago

I am facing the same issue when I used the following settings on my physical iPhone: Settings -> Camera -> Formats -> Most Compatible.

github-actions[bot] commented 1 month ago

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

sanalkv commented 1 month ago

Faced the issue with live photos taken with iPhone camera app. If I turn off the live feature, I'm able to upload the image.

github-actions[bot] commented 3 weeks ago

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

github-actions[bot] commented 1 week ago

This issue was closed because it has been inactive for 14 days since being marked as stale.