MCPcopy Create free account
hub / github.com/apache/maka / readWorkspaceImage

Function readWorkspaceImage

packages/runtime/src/image-file.ts:23–35  ·  view source on GitHub ↗
(
  path: string,
)

Source from the content-addressed store, hash-verified

21}
22
23export async function readWorkspaceImage(
24 path: string,
25): Promise<{ bytes: Uint8Array; mimeType: ImageMimeType }> {
26 const size = await stat(path).catch(() => {
27 throw new Error('Image could not be read.');
28 });
29 if (!size.isFile()) throw new Error('Image path is not a file.');
30 if (size.size > MAX_READ_IMAGE_BYTES) throw imageTooLargeError();
31 const bytes = await readFile(path).catch(() => {
32 throw new Error('Image could not be read.');
33 });
34 return validateImageBytes(bytes);
35}
36
37export function validateImageBytes(bytes: Uint8Array): {
38 bytes: Uint8Array;

Callers 3

readFileMethod · 0.85
image-file.test.tsFile · 0.85

Calls 3

imageTooLargeErrorFunction · 0.85
validateImageBytesFunction · 0.85
isFileMethod · 0.80

Tested by

no test coverage detected