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

Function fileFromBinaryBytes

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

Source from the content-addressed store, hash-verified

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