Skip to content

Unable to converted the selected file to base64 in react-native:0.78.0 #816

@gkasireddy202

Description

@gkasireddy202

I have searched open and closed issues for this issue.

  • I have searched open and closed issues.

I have read and understood the license (link below).

  • I have read and understood the license.

Minimal reproducible example

I shared the code.

What platform(s) does this occur on?

iOS

Did you reproduce on a real device or emulator / simulator?

emulator / simulator

Steps to reproduce

import {pick,types,errorCodes,isErrorWithCode} from '@react-native-documents/picker';
import RNFS from 'react-native-fs';

try {
const res = await pick({
type: [types.allFiles],
mode:'open',
});
RNFS.readFile(res[0].uri, 'base64').then((base64String) => {

          console.log(base64String)
        })
        .catch((err) => {
           console.log(err)
        });
    } catch (err) {
        if (isErrorWithCode(err)) {
           console.log(errorCodes.OPERATION_CANCELED)
        } 
    }

Version: "@react-native-documents/picker": "^10.1.1",

Error:

Error: ENOENT: no such file or directory, open '/Users/Ravi/Library/Developer/CoreSimulator/Devices/B6A42493-15C2-4D12-BB3D-B4944BA4BC2B/data/Containers/Shared/AppGroup/76C3D593-3536-4761-A65B-FCD735677B5A/File%20Provider%20Storage/dummy.pdf'

If the issue is related to specific file(s), I have linked the files so that others can reproduce exactly what I see.

  • I have attached files necessary to reproduce the problem (if applicable).

Stacktrace of the crash (if applicable)

try {
const res = await pick({
type: [types.allFiles],
mode:'open',
});
RNFS.readFile(res[0].uri, 'base64').then((base64String) => {

          console.log(base64String)
        })
        .catch((err) => {
           console.log(err)
        });
    } catch (err) {
        if (isErrorWithCode(err)) {
           console.log(errorCodes.OPERATION_CANCELED)
        } 
    }

Your computer environment

System:
  OS: macOS 15.3
  CPU: (12) x64 Intel(R) Core(TM) i7-8750H CPU @ 2.20GHz
  Memory: 76.63 MB / 16.00 GB
  Shell:
    version: "5.9"
    path: /bin/zsh
Binaries:
  Node:
    version: 21.7.3
    path: /usr/local/bin/node
  Yarn: Not Found
  npm:
    version: 10.5.0
    path: /usr/local/bin/npm
  Watchman:
    version: 2023.03.13.00
    path: /usr/local/bin/watchman
Managers:
  CocoaPods:
    version: 1.14.3
    path: /Users/gopi/.rvm/gems/ruby-2.7.6/bin/pod
SDKs:
  iOS SDK:
    Platforms:
      - DriverKit 24.2
      - iOS 18.2
      - macOS 15.2
      - tvOS 18.2
      - visionOS 2.2
      - watchOS 11.2
  Android SDK:
    API Levels:
      - "23"
      - "27"
      - "32"
      - "33"
      - "34"
      - "35"
    Build Tools:
      - 29.0.2
      - 30.0.3
      - 33.0.1
      - 34.0.0
      - 35.0.0
    System Images:
      - android-32 | Google APIs Intel x86 Atom_64
      - android-32 | Google Play Intel x86 Atom_64
      - android-33 | Google APIs Intel x86 Atom_64
      - android-33 | Google Play Intel x86 Atom_64
    Android NDK: Not Found
IDEs:
  Android Studio: 2024.2 AI-242.23726.103.2422.13103373
  Xcode:
    version: 16.2/16C5032a
    path: /usr/bin/xcodebuild
Languages:
  Java:
    version: 18.0.2.1
    path: /Library/Java/JavaVirtualMachines/jdk-18.0.2.1.jdk/Contents/Home/bin/javac
  Ruby:
    version: 2.7.6
    path: /Users/gopi/.rvm/rubies/ruby-2.7.6/bin/ruby
npmPackages:
  "@react-native-community/cli":
    installed: 15.0.1
    wanted: 15.0.1
  react:
    installed: 19.0.0
    wanted: 19.0.0
  react-native:
    installed: 0.78.0
    wanted: 0.78.0
  react-native-macos: Not Found
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: true
  newArchEnabled: true
iOS:
  hermesEnabled: true
  newArchEnabled: true

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions