Skip to content

Instantly share code, notes, and snippets.

@woss
Created April 28, 2023 11:39
Show Gist options
  • Save woss/c582a067b3b06e8f99d9b37f2468f64f to your computer and use it in GitHub Desktop.
Save woss/c582a067b3b06e8f99d9b37f2468f64f to your computer and use it in GitHub Desktop.
import axios from "axios";
import FormData from "form-data";
// create DL stream
const dl = await axios.get('url.tar', {
responseType: "stream",
});
// create multipart
const formData = new FormData();
formData.append('file', dl.data);
// directly proxy the stream to the upstream
const up = await axios({
method: 'POST',
url: `upstream-url/api/post/add`,
data: formData,
maxContentLength: Infinity
});
console.log(up.data)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment