Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Temporary file could not be created. #997

Closed
whedamd opened this issue Mar 14, 2022 · 36 comments
Closed

Temporary file could not be created. #997

whedamd opened this issue Mar 14, 2022 · 36 comments
Labels
iOS Issue applies to iOS platform stale triage Further information is requested

Comments

@whedamd
Copy link

whedamd commented Mar 14, 2022

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

@whedamd whedamd added the new issue An issue that hasn't yet been seen from the maintainer label Mar 14, 2022
@gabdsg
Copy link

gabdsg commented Mar 14, 2022

Same problem here

@nobezawa
Copy link

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
Copy link
Owner

Hi, how are you picking the files?

@miguelpruivo miguelpruivo added triage Further information is requested iOS Issue applies to iOS platform and removed new issue An issue that hasn't yet been seen from the maintainer labels Mar 15, 2022
@MyisCARRY
Copy link

MyisCARRY commented Mar 15, 2022

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
Copy link

gabdsg commented Mar 15, 2022

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
Copy link
Owner

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
Copy link

Same issue happening with me on a real device.

@squaredx
Copy link

squaredx commented Apr 27, 2022

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
Copy link
Author

whedamd commented Apr 30, 2022

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
Copy link

pinguluk commented May 18, 2022

+1 for any picture on simulator

@pinguluk
Copy link

pinguluk commented May 18, 2022

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
Copy link

@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.

2022-06-14.16-07-54.mp4

@bawantha
Copy link

bawantha commented Jul 7, 2022

Why this issue is closed?

@conceptualben
Copy link

conceptualben commented Jul 27, 2022

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
Copy link

tiagocdr commented Sep 9, 2022

Will there be a resolution for this ?

@yahu1031
Copy link

yahu1031 commented Sep 9, 2022

May be this should be fixed from apple 😅

@WaheedHussainHaans
Copy link

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

@JaFa13
Copy link

JaFa13 commented Oct 4, 2022

This is still not working

@phongkien
Copy link

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

@NabeelAbid1812
Copy link

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
Copy link

@NabeelAbid1812 sure

@anasboyka
Copy link

anasboyka commented Dec 19, 2022

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

mac mini m1

@donpui
Copy link

donpui commented Jan 14, 2023

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
Copy link

Khodosov commented Oct 17, 2023

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
Copy link

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
Copy link

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

@ghost
Copy link

ghost commented Mar 13, 2024

I am facing this issue on real ios device.

@gonciuu
Copy link

gonciuu commented Jun 6, 2024

Also facing the same issue on real iphone device

@joachimbulow
Copy link

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

@miguelpruivo miguelpruivo reopened this Aug 25, 2024
@Xarvis
Copy link

Xarvis commented Aug 26, 2024

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

Copy link

github-actions bot commented Sep 3, 2024

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

@github-actions github-actions bot added the stale label Sep 3, 2024
@sanalkv
Copy link

sanalkv commented Sep 4, 2024

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 github-actions bot removed the stale label Sep 5, 2024
Copy link

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

@github-actions github-actions bot added the stale label Sep 12, 2024
Copy link

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

@TP-113
Copy link

TP-113 commented Oct 27, 2024

#997 (comment)
I have a same issue.

Different results were seen depending on the format of the image ("Settings" -> "Formats"). "High Efficiency" succeeded in picking in live photos, while "Most Compatible" failed.
IMG_9359

@bahadurh
Copy link
Contributor

bahadurh commented Dec 4, 2024

I have implemented a workaround for selecting multiple photos. Instead of failing completely, the process now retrieves the selected photos successfully. This improvement is included in PR #1639.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
iOS Issue applies to iOS platform stale triage Further information is requested
Projects
None yet
Development

No branches or pull requests