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

292
Visualizações
why get 413 error when upload image with 'expo ImagePicker camera'?

If I take a photo with the camera, I get this error: Error: Request failed with status code 413.

But if I select and upload a photo from the phone gallery, there will be no problem. The size of the photo I upload was below 5mb both with the camera and with the gallery.

const formData = new FormData();

    let localUri = image.value.uri;
    let filename = localUri.split('/').pop();
    let type = mime.getType(localUri);

    image.blob &&
      formData.append('photo', { uri: localUri, name: filename, type });


const pickImageFromGallery = async () => {
    let result = await ImagePicker.launchImageLibraryAsync({
      mediaTypes: ImagePicker.MediaTypeOptions.Images,
      allowsEditing: true,
      aspect: [16, 9],
      base64: true,
    });

    if (!result.cancelled) {
      const response = await fetch(result.uri);
      const blob = await response.blob();
      if (blob.size && blob.size / 1024 < 5120) {
        setImage({
          value: result,
          blob: blob,
          error: false,
        });
      } else {
        alert('File size is too large. Please upload files below 5MB!');
      }
    }
  };

const pickImageFromCamera = async () => {
    let result = await ImagePicker.launchCameraAsync({
      mediaTypes: ImagePicker.MediaTypeOptions.Images,
      allowsEditing: true,
      aspect: [16, 9],
      base64: true,
    });

    if (!result.cancelled) {
      const response = await fetch(result.uri);
      const blob = await response.blob();

      if (blob.size && blob.size / 1024 < 5120) {
        setImage({
          value: result,
          blob: blob,
          error: false,
        });
      } else {
        alert('File size is too large. Please upload files below 5MB!');
      }
    }
  };
about 4 years ago · Juan Pablo Isaza
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