Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

141
Visualizações
Convert image to base64 and send to graphQl in React Native

How can I convert an image selected from imagepicker into base64 before sending it to graphql?

I set useState varaibles to set

const [image, setImage] = useState(null);

What can i do here to convert?

   const choosePhotoFromLibrary = async() => {
    const permissionResult = await ImagePicker.requestMediaLibraryPermissionsAsync();

    if (permissionResult.granted === false) {
      alert("Permission to access camera roll is required!");
      return;
    }

    const pickerResult = await ImagePicker.launchImageLibraryAsync();

    if(!pickerResult.cancelled) {
        setImage(pickerResuls.uri);
    }

then I grab the image from and set it to the useState varaible

 <View style={styles.picContainer}>
     <AddPicButton
      onPress= {choosePhotoFromLibrary}
      image= {image}
      />
      <Text style={styles.bottomText}>ADD A PICTURE</Text>

 </View>
about 4 years ago · Juan Pablo Isaza
2 Respostas
Responde à pergunta

0

ImageEditor.cropImage(imageUrl, imageSize, (imageURI) => {
      ImageStore.getBase64ForTag(imageURI, (base64Data) => {
          // base64Data contains the base64string of the image
      }, (reason) => console.error(reason));
 }, (reason) => console.error(reason));
about 4 years ago · Juan Pablo Isaza Relatório

0

it turns out ImagePicker has its own base64 conversion

const pickImage = async () => {
        // No permissions request is necessary for launching the image library
        let result = await ImagePicker.launchImageLibraryAsync({
            mediaTypes: ImagePicker.MediaTypeOptions.Images,
            allowsEditing: true,
            aspect: [4, 3],
            quality: 0,
            base64: true
        });

        console.log(result);

        if (!result.cancelled) {
            setImage(result.uri);
        }
        console.log(result);
        
    };
about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda