react-native-compressor icon indicating copy to clipboard operation
react-native-compressor copied to clipboard

getRealPath(uri, "image") bug?

Open yudistiraashadi opened this issue 2 years ago • 5 comments

Current behavior

My current code:

const res = await DocumentPicker.pickSingle({
    type: [DocumentPicker.types.images],
})

let realPath = await getRealPath(res.uri, "image")

const result = await ImageCompressor.compress(realPath, {
    compressionMethod: "auto",
})

getRealPath(uri, "image") return the original uri, but with added file:// in front. When I used the uri returned from getRealPath() on

const result = await ImageCompressor.compress(realPath, {
    compressionMethod: "auto",
})

An error shows image

This is the returned value from DocumentPicker.pickSIngle() image

This is the returned value from getRealPath(uri, "image") image

Expected behavior

getRealPath(uri, "image") return an uri I can use for image.compress()

Platform

  • [X] Android

React Native Version

0.67.2

React Native Compressor Version

1.5.2

Reproducible Steps And Demo

  • Pick an image using react-native-document-picker in Android, it will return an uri with content://
  • Input the uri on getRealPath(uri, "image")
  • Input the real path returned from getRealPath(uri, "image") on image.compress()

yudistiraashadi avatar Mar 07 '22 03:03 yudistiraashadi

@yudistiraAshadi can you tell me your android device and OS modal and can you add a reproducible GitHub example here?

numandev1 avatar Mar 07 '22 05:03 numandev1

@yudistiraAshadi can you tell me your android device and OS modal and can you add a reproducible GitHub example here?

This is in Android Emulator from Android Studio image

yudistiraashadi avatar Mar 07 '22 07:03 yudistiraashadi

@yudistiraAshadi can you tell me your android device and OS modal and can you add a reproducible GitHub example here?

I included the steps and a copy of my code on top. I hope that's enough.

yudistiraashadi avatar Mar 07 '22 07:03 yudistiraashadi

@yudistiraAshadi

This is the reasoni think.. u should give permission.

const granted = await PermissionsAndroid.request(
      PermissionsAndroid.PERMISSIONS.WRITE_EXTERNAL_STORAGE,
      {
        title: 'Storage Permission',
        message: 'App needs access to memory to upload the file ',
      },
    );
    if (granted != PermissionsAndroid.RESULTS.GRANTED) {
      Toast.show({
        type: 'error',
        text1: 'Permission Issue.',
        text2: 'You need to give storage permission to upload the file.',
      });

      return false;
    }

thareekanvar avatar Jun 19 '22 09:06 thareekanvar

I have the same error, any updates ?

Raghavmunjal avatar Aug 18 '22 07:08 Raghavmunjal

This issue is stale because it has been open 365 days with no activity. Remove stale label or comment or this will be closed in 7 days.

github-actions[bot] avatar Aug 19 '23 01:08 github-actions[bot]

Does this issue still exist?

numandev1 avatar Sep 15 '23 07:09 numandev1

fixed in the latest version, please feel free to reopen this issue again if this issue happens again

numandev1 avatar Oct 02 '23 22:10 numandev1