Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

805
Vistas
Convert image into binary file in React Native

I am new to react native and I am practicing converting images into binary files. I randomly downloaded the image from the internet. I am trying to convert images into binary files to upload to the server through API. The server takes input as a binary file. I have attached the code below. I searched on the internet but could not find the solution.

import React from 'react'
import {
    View,
    Text,
    StyleSheet,
    Image,
    Button,
    Alert
} from 'react-native'


let imagePath = './src/image/macTest.jpeg'

const imageToBinary = (imagePath) => {
    //Alert.alert(imagePath)

// this function needs to convert image into the binary file
}

const App = () => {
    return (
        <View>
            <Text style={styles.headerStyle}> Image </Text>

            <Image
                style={styles.imageStyle}
                source= {require('./src/image/macTest.jpeg')}
            />

            <Button 
                title="Binary Value"
                onPress={() => imageToBinary(imagePath)}
            />

            <View style= {styles.binaryStyle}>
               <Text>
               // binary value of the image
               </Text>
            </View>
        </View>
    )
}

const styles = StyleSheet.create({

    headerStyle:{
        fontSize: 20,
        textAlign: 'center',
        margin: 15
    },

    imageStyle:{
        alignItems: 'center',
        height: 300,
        width: 450,
    },

    binaryStyle: {
        borderWidth: 1,
        borderColor: 'black',
        width: 400,
        height: 250,
        margin: 5
    }

})

export default App;
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

If you're using Expo there is FileSystem:

https://docs.expo.dev/versions/latest/sdk/filesystem/#filesystemreadasstringasyncfileuri-options

Example:

const img = await FileSystem.readAsStringAsync(photo.uri, { encoding: 'base64' });

Another alternative is react-native-image-picker:

https://www.npmjs.com/package/react-native-image-picker

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda