Skip to content
a list for 'against comparison'
  • Pages
    • a list for 'against comparison'
      • Music Copyright as a Service.
      • MusicMole
        • Google Sheets
        • Connections
      • Infranodus
        • Sample CSV
      • Why do ChatBot's interest me?
      • Music Ingest for AVID Media Composer.
        • Back End
      • Using Coda AI to classify research
      • Sync Tech - some advice.
      • Cursor.ai
      • When New Tech Creates More Work, Not Less
    • Pipedream
      • Avid Media Composer - JSON to ALE
      • Determine Mime-Type - Audio
      • FFMPEG - Convert to WAV

Determine Mime-Type - Audio


import fs from "fs";
import mime from "mime-types";

export default defineComponent({
async run({ steps, $ }) {
// adjust filePath to your own use-case.
const filePath = steps.download_audio_to_tmp.$return_value.filePath;

try {
// Read the downloaded file
const fileBuffer = await fs.promises.readFile(filePath);
const mimeType = mime.lookup(filePath);

// List of known audio MIME types
const audioMimeTypes = [
"audio/mpeg",
"audio/aac",
"audio/ogg",
"audio/wav",
"audio/x-flac",
"audio/mp4",
];

const isAudio = mimeType && audioMimeTypes.includes(mimeType);

return { filePath, fileName: steps.download_audio_to_tmp.$return_value.fileName, mimeType, isAudio };
} catch (error) {
$.export('error', error);
throw new Error(`Failed to detect the MIME type of the file: ${error.message}`);
}
}
});
 
Want to print your doc?
This is not the way.
Try clicking the ··· in the right corner or using a keyboard shortcut (
CtrlP
) instead.