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

Function fileFromBinaryBytes

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

Source from the content-addressed store, hash-verified

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