@epilot/file-client
v1.13.1
Published
Client library for the epilot File API
Downloads
1,880
Maintainers
Readme
@epilot/file-client
Client library for epilot File API
Uses openapi-client-axios
Installation
npm install --save @epilot/file-client
Usage
import fs from 'fs';
import { getClient } from '@epilot/file-client';
const fileClient = getClient();
// get upload params
const uploadFileRes = await fileClient.uploadFile(null, { filename: 'document.pdf', mime_type: 'application/pdf' });
const uploadParams = uploadFileRes.data;
// upload file to S3
const file = fs.readFileSync('./document.pdf')
const uploadRes = await fileClient.put(
uploadParams.upload_url,
file,
{ headers: { 'content-type': 'application/json' }}
);
// save file as an entity
const uploadParams = await fileClient.saveFile(
null,
{ s3ref: uploadParams.s3ref, access_control: 'private' },
);
Documentation
https://docs.epilot.io/docs/files/file-api