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

251
Vistas
How to Upload Image File To server in react native

By selecting Image or File Gallery My data Look Like this

[{"fileCopyUri": "content://com.android.providers.media.documents/document/image%3A55539", "name": "c6235fa2-aa7f-4e06-a664-7e805de2f883.jpg", "size": 1967925, "type": "image/jpeg", "uri": "content://com.android.providers.media.documents/document/image%3A55539"}]

{"fileCopyUri": "content://com.android.providers.media.documents/document/document%3A55435", "name": "Maha Police-2019 222.pdf", "size": 302194, "type": "application/pdf", "uri": "content://com.android.providers.media.documents/document/document%3A55435"}

By Capturing Image from Camera My data look like this

{"assets": [{"fileName": "rn_image_picker_lib_temp_c96a3333-f53f-4143-af29-e0270c8e6a8c.jpg", "fileSize": 24925, "height": 550, "type": "image/jpeg", "uri": "file:///data/user/0/com.sanayaapp/cache/rn_image_picker_lib_temp_c96a3333-f53f-4143-af29-e0270c8e6a8c.jpg", "width": 247}]}

I am Sending Data through FormData like this


const formData = new FormData();


formData.append('SellerBrandsWeDeal', selectedFile);

fetch('http://api', {
          method: 'POST',
          headers: {Accept: '*/*', 'Content-Type': 'multipart/form-data'},
          body: formData,
})

But its keep saying network error. please help thanks

about 4 years ago · Juan Pablo Isaza
3 Respuestas
Responde la pregunta

0

you can use rn-fetch-blob to code yours picture in base64 string , then you can send base64 string to server. Like this - React-Native: Convert image url to base64 string

about 4 years ago · Juan Pablo Isaza Denunciar

0

You can create image object like this:

    selectedFile = {
                   uri:
"content://com.android.providers.media.documents/document/image%3A55539",
                    name: "c6235fa2-aa7f-4e06-a664-7e805de2f883.jpg",
                    type: "image/jpeg"
                     }
about 4 years ago · Juan Pablo Isaza Denunciar

0

For me I convert the image to base64 and upload it to the data base as a blob. Here a function to convert it to base64 , all you need is to implement it . The result of the conversion it stored in image state .

const handleFile = (e) => {
let file = e.target.files[0];
getBase64(file)
  .then((result) => {
    // console.log("result",result)
    setImage({
      base64URL: result,
    });
  })
  .catch((err) => {
    setUploadFileError(err);
  });

};

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