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

514
Vistas
How to reduce received Base64 string after cropping an image?

I am using the react-cropper npm package, to crop an image on upload. The uploaded images are in jpeg, jpg, and png format. After the image is cropped, I receive the image in BASE64 format. When I try to send the image to the backend, I receive an error message as below. {error: "Bad Request" message: "Field value too long" statusCode: 400}

Is there a way to either reduce the URI or any other options? Actually stuck with this for too long and was unable to identify a solution.

const handleUpload = async (uri) => {
    const myHeaders = new Headers();
    myHeaders.append('Authorization', `Bearer ${appRef.get('X-AUTH-TOKEN')}`);

    const formdata = new FormData();
    formdata.append('file', uri);
    formdata.append('type', 'base64');

    const requestOptions = {
      method: 'POST',
      headers: myHeaders,
      body: formdata,
      redirect: 'follow',
    };

    fetch(`https://prod-main.com/nj/file-upload`, requestOptions)
      .then(response => response.text())
      .then(result => console.log(result))
      .catch(error => console.log('error', error));
  };

Have attached a sandbox link that contains a file named base64Image where the URI received is added. https://codesandbox.io/s/epic-ives-9eqpce?file=/base64Image

about 4 years ago · Santiago Trujillo
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