Skip to main content

Files

Manage binary files (PDFs, CSVs, images, documents, etc.) attached to your Mentiora project. Files are stored server-side and can be used for analysis, knowledge bases, or any custom workflow.

Upload a File

import { readFileSync } from 'fs';

const result = await client.files.upload({
filename: 'report.pdf',
content: readFileSync('./report.pdf'),
mimeType: 'application/pdf',
description: 'Q1 sales report',
});

console.log(`Uploaded: ${result.fileId}`);

The SDK handles base64 encoding automatically. Maximum file size is 50 MB.

List Files

// List all files
const files = await client.files.list();
console.log(`Total: ${files.totalCount}`);
for (const file of files.data) {
console.log(`${file.filename} (${file.size} bytes)`);
}

// Search by name or description
const results = await client.files.list({ query: 'report' });

// Paginate
const page2 = await client.files.list({ offset: 10, count: 10 });

Get File Metadata

const file = await client.files.get('019d6d5d-d384-7793-9e0f-2592a9986021');
console.log(`${file.filename}${file.mimeType}${file.size} bytes`);

Download a File

const content = await client.files.download('019d6d5d-d384-7793-9e0f-2592a9986021');
// content is a Uint8Array — write to disk or process in memory
import { writeFileSync } from 'fs';
writeFileSync('./downloaded-report.pdf', content);

Delete a File

Deletion fails with a 409 Conflict error if the file is still referenced by a knowledge base document. Remove the reference first, then delete.

const result = await client.files.delete('019d6d5d-d384-7793-9e0f-2592a9986021');
console.log(`Deleted: ${result.deleted}`);

Supported File Types

The platform accepts a wide range of file types including:

  • Documents: PDF, DOCX, DOC, ODT, RTF
  • Structured data: CSV, TSV, JSON, JSONL, XML, YAML
  • Text: TXT, Markdown, HTML
  • Images: PNG, JPEG, GIF, WebP, SVG, TIFF, BMP
  • Email: EML
  • eBooks: EPUB

See Also