Load file from build assets using file system.

Please provide the following:

  1. SDK Version: 43
  2. Platforms(Android/iOS/web/all): android and ios
  3. Add the appropriate “Tag” based on what Expo library you have a question on.

I need to access the contents of an svg file as a string in order to parse selective data from it. react-native-svg does not fit my use-case because I am not trying to display the whole svg. What I’d like to do is get the file from my assets folder and then load it with the expo file system API.

I am, however, getting an error coming from the uri. When I get the URI using expo-asset like this

import { Asset } from 'expo-asset';
const uri = Asset.fromModule(require('./assets/sample.svg')).uri

it gives my uri as something like which, when I use it with

readAsStringAsync(uri).then(data => console.log(data))

I get the promise rejection with the error Unsupported URI scheme.

What is the correct way to do what I’m trying to do here?

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.