diff --git a/src/api/resources.ts b/src/api/resources.ts index 0f5ae79..85729af 100644 --- a/src/api/resources.ts +++ b/src/api/resources.ts @@ -1,4 +1,5 @@ import { sendMessage } from '../ws/websocket'; +import { base64ToBytesArray } from '../helpers'; export function getFiles(): Promise { return sendMessage('resources.getFiles'); @@ -7,3 +8,19 @@ export function getFiles(): Promise { export function extractFile(path: string, destination: string): Promise { return sendMessage('resources.extractFile', { path, destination }); }; + +export function readFile(path: string): Promise { + return sendMessage('resources.readFile', { path }); +}; + +export function readBinaryFile(path: string): Promise { + return new Promise((resolve: any, reject: any) => { + sendMessage('resources.readBinaryFile', { path }) + .then((base64Data: string) => { + resolve(base64ToBytesArray(base64Data)); + }) + .catch((error: any) => { + reject(error); + }); + }); +};