MCPcopy Create free account
hub / github.com/UsefulSoftwareCo/executor / fileFromBinaryBytes

Function fileFromBinaryBytes

packages/plugins/openapi/src/sdk/invoke.ts:567–582  ·  view source on GitHub ↗
(
  bytes: Uint8Array,
  hint: OperationFileHint,
  contentType: string | null | undefined,
)

Source from the content-addressed store, hash-verified

565};
566
567const fileFromBinaryBytes = (
568 bytes: Uint8Array,
569 hint: OperationFileHint,
570 contentType: string | null | undefined,
571): ToolFileValue => {
572 const hintedMimeType = contentType ?? readHintMimeType(hint, "application/octet-stream");
573 return {
574 _tag: "ToolFile",
575 mimeType: isGenericMimeType(hintedMimeType)
576 ? (sniffMimeType(bytes) ?? hintedMimeType)
577 : hintedMimeType,
578 encoding: "base64",
579 data: bytesToBase64(bytes),
580 byteLength: bytes.byteLength,
581 };
582};
583
584type FormDataRecord = Parameters<typeof HttpClientRequest.bodyFormDataRecord>[1];
585type FormDataCoercible = FormDataRecord[string];

Callers 1

invoke.tsFile · 0.85

Calls 4

readHintMimeTypeFunction · 0.85
isGenericMimeTypeFunction · 0.85
sniffMimeTypeFunction · 0.85
bytesToBase64Function · 0.85

Tested by

no test coverage detected