How to read binary file using Vega API

I think I am missing something, but I am looking through documentation and cannot find any way to read binary file using Vega API.

Could someone point me into the right direction?

Hi @Boris_Rekhtman,

Thank you for your question about reading binary files using Vega API.

You can use @amazon-devices/expo-file-system for file operations in Vega apps. This library provides methods for reading, writing, downloading, and uploading files.

Key methods available:

  • readAsStringAsync - Read text files
  • writeAsStringAsync - Write text files
  • downloadAsync - Download files from network
  • uploadAsync - Upload files to network
  • copyAsync, moveAsync, deleteAsync - File operations
  • getInfoAsync - File metadata

Storage locations:

  • FileSystem.documentDirectory - Persistent storage
  • FileSystem.cacheDirectory - Temporary files
  • FileSystem.bundleDirectory - Bundled assets (read-only)

Full documentation with examples: expo-file-system | Vega Libraries

Note: The API currently supports string-based read/write and network download/upload. For reading binary files directly into memory for processing, you may need to explore additional solutions or custom native modules.

Thanks for helping us improve the Vega platform.

Warm regards,
Aishwarya

Thank you, Aishwarya. Yes, I am using @amazon-devices/expo-file-system, but (based on what you said) reading binary files is not supported in Vega API.

Couple questions:

  • Can you recommend libraries or modules to do that?

  • If I implement file access in Turbo Module, how do I reference the filesystem? Is /data and /pkg still available from the native code?

Thank you,

Boris

Hi @Boris_Rekhtman,

Regarding filesystem paths in Turbo Modules: The Vega documentation confirms that /data/, /cache/, and /pkg/bundle/ paths exist in the Vega environment. Please review the Turbo Module documentation to confirm whether these paths are accessible from native C++ code:

Regarding binary file reading: I understand that the current @amazon-devices/expo-file-system API supports string-based operations but doesn’t directly support reading binary files into memory for processing. Our internal team is looking into this and will get back to you shortly.

Thanks for your patience!

Warm regards,
Aishwarya

Hello Boris,

You are correct that we currently don’t support binary file reading. Right now, you can work around this by using KeplerFileSystemTM with UTF-8 strings and using base64 conversion. We will study when we can bring this feature into Vega roadmap, but haven’t planned it as of today.

Thanks for bringing this to our attention,

Christian

Hi @Boris_Rekhtman ,

Thank you for your patience.

As mentioned by @Christian_Van_Boven1 , we have reported this to our team as a feature, however, we cannot say when this will be worked on or implemented.

We will close this post for now, and if and when this gets implemented, you will be notified via blog posts and tech doc updates.

Thanks,
Rohit

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