import { PersonaClient } from '@personaai/sdk';
import { readFile } from 'node:fs/promises';
const userClient = new PersonaClient({
baseUrl: process.env.PERSONA_BASE_URL!,
credential: process.env.PERSONA_CREDENTIAL!,
externalUserId: 'user_123',
});
// Upload a resume and associate it with a conversation.
const resume = await readFile('./resume.pdf');
const file = await userClient.files.upload({
filename: 'resume.pdf',
content: resume,
contentType: 'application/pdf',
threadId: 'thread_456',
});
// Download it back later.
const response = await userClient.files.download(file.id);
const bytes = Buffer.from(await response.arrayBuffer());
console.log('Downloaded', bytes.length, 'bytes');