Closed meypod closed 1 year ago
well I have written a helper function myself, I haven't test the production build but I guess it should work on that as well
async function loadFile(resourceId: number) {
const uri = Image.resolveAssetSource(resourceId).uri;
let resourcePath: string | undefined = undefined;
if (uri.startsWith('http')) {
resourcePath = Dirs.CacheDir + '/resource-' + resourceId;
await FileSystem.fetch(uri, {
path: resourcePath,
});
}
return FileSystem.readFile(resourcePath ? resourcePath : uri);
}
Nope, it returns a string in production build sadly I think I have to copy the asset first then load it
It would be nice if we could read a file from the id returned by require() this would simplify loading assets such as a text file
the only problem is, in development mode, the resource resolves to a web url that points to development server
it would be nice to support the dev mode as well