Skip to main content

File upload

Upload and analyze local files.

Node.js example

import { Mappa } from "@mappa-ai/mappa-node";
import { readFile } from "fs/promises";

const mappa = new Mappa({
apiKey: process.env.MAPPA_API_KEY!,
});

async function analyzeLocalFile(filePath: string) {
const buffer = await readFile(filePath);

const media = await mappa.files.upload({ file: buffer });

const report = await mappa.reports.generate({
media: { mediaId: media.mediaId },
output: {
template: "general_report",
},
target: { strategy: "dominant" },
});

return report;
}

const report = await analyzeLocalFile("./recordings/meeting.mp3");
console.info(report.markdown);

Python example

from mappa import Mappa

mappa = Mappa(api_key=os.environ["MAPPA_API_KEY"])

def analyze_local_file(file_path: str):
with open(file_path, "rb") as f:
media = mappa.files.upload(file=f)

report = mappa.reports.generate(
media={"media_id": media.media_id},
output={"template": "general_report"},
target={"strategy": "dominant"},
)

return report

report = analyze_local_file("./recordings/meeting.mp3")
print(report.markdown)