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

Make getDataFromUri Public and Support File URIs for Attachments #4605

Open
bondarenkod opened this issue Feb 26, 2025 · 1 comment
Open

Comments

@bondarenkod
Copy link

I’d like to request that the Sentry React Native SDK expose the getDataFromUri function as a public API. Right now, I’m importing it privately like this:

import { NATIVE } from '@sentry/react-native/dist/js/wrapper';

const jsByteArray = await NATIVE.getDataFromUri(image.url);

if (bd) {
  const attachment: Attachment = {
    filename: file.name || `file_${0}.${mime.getType(file.mediaContentType)}`,
    data: jsByteArray,
    contentType: file.mediaContentType,
  };
  attachments.push(attachment);
}

Depending on an internal method isn’t ideal—it feels brittle and may stop working if the SDK changes. Exposing getDataFromUri (or providing a similar official method) would make it safer and more straightforward to attach user-supplied files in a feedback workflow.

Additionally, it would be great if the SDK directly supported attaching files via a platform-based file URI (e.g., file://...). The code could look like this:

const attachment: Attachment = {
  filename: file.name || `file_${index}.${mime.getType(file.mediaContentType)}`,
  uri: image.url, // "file://etc"
  contentType: file.mediaContentType,
};

Internally, Sentry could then convert that URI into the data it needs. This would simplify the process for developers who want to attach files without manually handling the conversion. If there’s another recommended approach, I’d love to hear it—otherwise, making getDataFromUri public (and potentially enhancing it to handle URIs directly) would be a big help.

@kahest
Copy link
Member

kahest commented Feb 27, 2025

Hey @bondarenkod thanks for the suggestion, we'll discuss and follow up here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: No status
Status: Needs Discussion
Development

No branches or pull requests

3 participants