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

151
Visualizações
Send received file to an axios multipart/form-data request

I want to fetch some data from a server and send it to another server. The data involved is a file. Is there any way to directly send the received file to the next axios request without saving it in the filesystem first?

I've tried something like:

let res = axios({
  method: 'get',
  url: 'someurl.com/image.png',
  responseType: 'stream'
})

axios.post(url2, {data: res.data}, {headers:{'Content-Type':'multipart/form-data'})}

and it doesn't seem to work.

So is there any way to do the above? Or should I go about it in a different manner?

over 4 years ago · Santiago Trujillo
2 Respostas
Responde à pergunta

0

Try this if you are using async/await

const { data } = await axios.get('/some_url', {...configs, responseType: 'stream'})


// pass it to another request
await axios.post('/some_other_url', data, config)
over 4 years ago · Santiago Trujillo Relatório

0

axios call returns a promise. Can you try the following snippet and see if it works?

axios({
  method: 'get',
  url: 'someurl.com/image.png',
  responseType: 'stream'
}).then((res) => {
  axios.post(url2, {data: res.data}, {headers:{'Content-Type':'multipart/form-data'})}
});
over 4 years ago · Santiago Trujillo 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