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
export const saveLiveSwitchRecording = async ( | |
recordingId: string, | |
channelId: string, | |
fileName: string, | |
type: "video" | "audio" | |
) => { | |
const file = makeLiveSwitchRecordingFile(recordingId, channelId, fileName); | |
const format = fileName.substring(fileName.indexOf(".") + 1); | |
const writeStream = file.createWriteStream({ | |
metadata: { | |
contentType: `${type}/${format}`, | |
}, | |
}); | |
const readStream = await axios.get(`https://api.liveswitch.io/recordings/${recordingId}/url?api-version=1.0`, { | |
headers: { | |
"X-API-Key": getEnvVar("LIVESWITCH_API_KEY"), | |
}, | |
responseType: "stream", | |
}); | |
const pipedStreams = readStream.data.pipe(writeStream); | |
return new Promise((resolve, reject) => { | |
pipedStreams.on("error", (err: string) => { | |
reject(err); | |
}); | |
pipedStreams.on("finish", () => { | |
// TODO : Do something useful | |
resolve("true"); | |
}); | |
}); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment