react-native-cameraroll: Error: The operation couldn’t be completed. (PHPhotosErrorDomain error -1.) iOS

Bug

Error: The operation couldn’t be completed. (PHPhotosErrorDomain error -1.) at Object.fn [as saveToCameraRoll] (NativeModules.js:99) at Function.save (CameraRoll.js:163) at Function.saveToCameraRoll (CameraRoll.js:169) at _callee2$ (VM5 index.bundle:209) at tryCatch (runtime.js:45) at Generator.invoke [as _invoke] (runtime.js:274) at Generator.prototype.<computed> [as next] (runtime.js:97) at tryCatch (runtime.js:45) at invoke (runtime.js:135) at runtime.js:170

Environment info

react-native info output:

System:
    OS: macOS 10.15.3
    CPU: (8) x64 Intel(R) Core(TM) i7-4770HQ CPU @ 2.20GHz
    Memory: 60.19 MB / 16.00 GB
    Shell: 5.7.1 - /bin/zsh
  Binaries:
    Node: 12.14.0 - /var/folders/7n/tg8wdbns7yvg3wqwnh_mzmp40000gn/T/yarn--1585096434645-0.8370493466760465/node
    Yarn: 1.22.1 - /var/folders/7n/tg8wdbns7yvg3wqwnh_mzmp40000gn/T/yarn--1585096434645-0.8370493466760465/yarn
    npm: 6.13.7 - /usr/local/bin/npm
  SDKs:
    iOS SDK:
      Platforms: iOS 13.2, DriverKit 19.0, macOS 10.15, tvOS 13.2, watchOS 6.1
  IDEs:
    Android Studio: 3.5 AI-191.8026.42.35.6010548
    Xcode: 11.2.1/11B53 - /usr/bin/xcodebuild
  npmPackages:
    react: 16.9.0 => 16.9.0
    react-native: 0.61.5 => 0.61.5

Library version: 1.4.0

Steps To Reproduce

  1. I am just calling the CameraRoll.saveToCameraRoll with the remote url …

Describe what you expected to happen:

  1. I expected the video to be saved in the photos
  2. I even tried it on the latest version and its still the same

Reproducible sample code

CameraRoll.saveToCameraRoll(url, 'video')
        .then(response => {
          console.log('***RES**');
          console.log(response);
          console.log('***RES**');
          this.setState({isDownloading: false});
          this.refs.completionToast.show('Download completed!');
        })
        .catch(error => {
          console.log('*****');
          console.log(error);
          console.log('*****');
          this.setState({isDownloading: false});
          this.refs.completionToast.show(
            'There was a problem downloading the video, please try again later',
          );
        });

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 10
  • Comments: 22 (1 by maintainers)

Commits related to this issue

Most upvoted comments

I solved it by roll back to version 1.4.0. yarn upgrade @react-native-community/cameraroll@1.4.0

@bartolkaruza Still happen to me “@react-native-community/cameraroll”: “^4.0.0”,

still happen to me. “@react-native-community/cameraroll”: “^4.0.0”,

Does anyone have time to help and make a PR with a fix for this issue? There appears to be a solution at #159 (comment) . I’m happy to review and merge a well tested PR. Cheers

@bartolkaruza I just opened a new PR #172 with the fixes! Works perfectly for me!

I got it working also using react-native 0.63.2, react-native-cameraroll 1.4.0 and rn-fetch-blob 0.12.0

Here is a sample code:

const handleDownloadVideo = async () => {
    const ext = getExtFromUrl(video);

    try {
      const file = await RNFetchBlob.config({
        fileCache: true,
        appendExt: ext,
      }).fetch('GET', video, {type: 'video'});
      const path = file.path();

      await CameraRoll.saveToCameraRoll(path, 'video');

      file.flush();
    } catch (error) {
      console.log(error);
    }
  };

still happen to me. “@react-native-community/cameraroll”: “^4.0.0”

🎉 This issue has been resolved in version 1.6.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

I solved it by roll back to version 1.4.0. yarn upgrade @react-native-community/cameraroll@1.4.0

thanks it’s work