Created
April 28, 2023 11:39
-
-
Save woss/c582a067b3b06e8f99d9b37f2468f64f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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