achorein / expo-share-intent

🚀 Simple share intent in an Expo Native Module
MIT License
152 stars 14 forks source link

Sharing files from the app into the same app results in an empty file #87

Closed dr-zr closed 1 month ago

dr-zr commented 1 month ago

Describe the bug I'm working on an instant messaging app that supports file sharing. Like in many other apps, you can share an image from the image view screen again in the same app (i.e. to a different recipient or a group chat). However, when I try to do that using expo-share-intent I found that the file size is 0 when receiving the file on Android. While on iOS the sharing works only for the first time. If I repeat the steps for sharing I get hasShareIntent: false.

To Reproduce

  1. add an image to your app
  2. share the image and choose your app as the destination
  3. try to preview the file received from the intent

Environment

info Fetching system and libraries information...
System:
  OS: macOS 14.5
  CPU: (8) arm64 Apple M1 Pro
  Memory: 82.97 MB / 16.00 GB
  Shell:
    version: "5.9"
    path: /bin/zsh
Binaries:
  Node:
    version: 20.7.0
    path: ~/.nvm/versions/node/v20.7.0/bin/node
  Yarn:
    version: 1.22.21
    path: ~/.nvm/versions/node/v20.7.0/bin/yarn
  npm:
    version: 10.1.0
    path: ~/.nvm/versions/node/v20.7.0/bin/npm
  Watchman:
    version: 2024.05.06.00
    path: /opt/homebrew/bin/watchman
Managers:
  CocoaPods:
    version: 1.15.2
    path: /opt/homebrew/bin/pod
SDKs:
  iOS SDK:
    Platforms:
      - DriverKit 23.5
      - iOS 17.5
      - macOS 14.5
      - tvOS 17.5
      - visionOS 1.2
      - watchOS 10.5
  Android SDK: Not Found
IDEs:
  Android Studio: 2023.3 AI-233.14808.21.2331.11842104
  Xcode:
    version: 15.4/15F31d
    path: /usr/bin/xcodebuild
Languages:
  Java:
    version: 17.0.10
    path: /usr/bin/javac
  Ruby:
    version: 2.6.10
    path: /usr/bin/ruby
npmPackages:
  "@react-native-community/cli": Not Found
  react:
    installed: 18.2.0
    wanted: 18.2.0
  react-native:
    installed: 0.74.3
    wanted: 0.74.3
  react-native-macos: Not Found
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: true
  newArchEnabled: false
iOS:
  hermesEnabled: true
  newArchEnabled: false

Additional context

dr-zr commented 1 month ago

When FileSystem.cacheDirectory is used this won't work. For whatever reason when FileSystem.documentDirectory is used the file is read properly and size is not 0