Advanced Usage
This section covers advanced configurations and best practices for using expo-document-scanner in production applications.
Handling Base64 Responses
While returning file URIs is the most efficient way to handle large images, sometimes you need the raw base64 data to send directly to an API.
Warning: Returning base64 strings for high-resolution images can consume significant memory. Always use a lower
qualitysetting if you must use base64, or prefer uploading files directly via theiruriusingFormData.
Uploading Images via URI (Recommended)
The most memory-efficient way to handle scanned documents is to leave them on the disk and upload them using FormData.
Error Handling
Always wrap your scanning logic in a try/catch block, and verify the status of the result. Note that user cancellations are returned as a status: 'cancel' result, rather than throwing an exception.
Exceptions are only thrown for critical failures, such as missing permissions or underlying native crashes.