Ingest Encoded File
User Intent
Operation
TypeScript (Canonical)
import { Graphlit } from 'graphlit-client';
import { ContentState, FileTypes } from 'graphlit-client/dist/generated/graphql-types';
import { readFileSync } from 'fs';
const graphlit = new Graphlit();
// Read file from disk
const fileBuffer = readFileSync('/path/to/document.pdf');
const base64Data = fileBuffer.toString('base64');
// Ingest encoded file
const response = await graphlit.ingestEncodedFile(
'document.pdf',
base64Data,
'application/pdf',
undefined,
undefined,
undefined,
undefined,
true,
{ id: workflowId },
[{ id: collectionId }],
undefined,
'upload-demo'
);
const contentId = response.ingestEncodedFile.id;
console.log(`File ingested: ${contentId}`);
// Retrieve the content
const content = await graphlit.getContent(contentId);
console.log(`File type: ${content.content.fileType}`);
console.log(`Markdown extracted: ${content.content.markdown?.substring(0, 100)}...`);Parameters
Required
Optional
Response
Developer Hints
ingestEncodedFile vs ingestUri
Aspect
ingestEncodedFile
ingestUri
When to Use ingestEncodedFile
Base64 Encoding Guide
MIME Type Reference
Variations
1. Browser File Upload
2. Email Attachment Processing
3. Ingesting with Workflow
4. Batch File Upload
5. Ingesting Programmatically Generated Files
Common Issues
Production Example
Last updated