Nacho Caballero : OK, I finally got it to work! Thanks and @UMZ235TK6 for the pointers along the way. In case anyone runs into any troubles uploading large files, here are all the pieces I needed to get it to work:
const FormData = require('form-data'); // send it as multipart/form-data instead of application/json
const form = new FormData();
form.append('title', 'test')
form.append('audio_file', fs.createReadStream('/tmp/myFile.mp3')) // fs.readFileSync gave a 504 error (Gateway timeout)
this.request = {
method: "POST",
url: `https://whatever.com`,
headers: {
Authorization: `Bearer ${process.env.MY_TOKEN}`,
'Content-Type': form.getHeaders()['content-type'] // Specifies `multipart/form-data; boundary=${form._boundary}`. It gave a 400 error without the boundary part
},
data: form,
maxContentLength: Infinity, // This was required for a 30MB file, but I'm not sure what the default size is.
};
this.response = await axios(this, this.request);