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

133
Visualizações
How can I post a photo and caption in the same publish on a facebook group api using FormData and axios?

Someone could help me, I'm trying to send a photo and caption into a group, but isn't working! I'd like send the photo that I recieve as base64 and send to a facebook group api.

What I'm doing? I got the base64 then convert into buffer and write it on a local disk, then I read it into a formdata. I load the data into a form this way =>

const form = new FormData();
    const fileContent = Buffer.from(url as any, 'base64');

    fs.writeFile('../tmp', fileContent, (err) => {
      if (err) return console.log(err)
    })


form.append('groupId', groupId)
 form.append('caption', caption) 
form.append('image ', fs.createReadStream('../tmp'))

In below is the axios configurations and request

 await client.post(`${config.facebook.BASE_URL}/${groupId}/photos`, form, {
  headers: {
    ...form.getHeaders(),
    Authorization: `OAuth ${config.facebook.token}`,
    'content-type': 'multipart/form-data',
    file_type: "image/jpeg",
  }

})

Note: This way I got the Error: Request failed with status code 500

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

I already resolved this although I changed de way that the file came to me, instead of receiving the image in base64 I'm receiving a signed url from google storage, and on the form.append, it's necessary to pass the name and the extension of the file, like this => form.append('source', image, 'file.jpg'); of course together with the other params and axios' configurations

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