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

Function fileFromBinaryBytes

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

Source from the content-addressed store, hash-verified

526};
527
528const fileFromBinaryBytes = (
529 bytes: Uint8Array,
530 hint: OperationFileHint,
531 contentType: string | null | undefined,
532): ToolFileValue => {
533 const hintedMimeType = contentType ?? readHintMimeType(hint, "application/octet-stream");
534 return {
535 _tag: "ToolFile",
536 mimeType: isGenericMimeType(hintedMimeType)
537 ? (sniffMimeType(bytes) ?? hintedMimeType)
538 : hintedMimeType,
539 encoding: "base64",
540 data: bytesToBase64(bytes),
541 byteLength: bytes.byteLength,
542 };
543};
544
545type FormDataRecord = Parameters<typeof HttpClientRequest.bodyFormDataRecord>[1];
546type 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