INNER CODE UNIT · TypeScript
isSupportedBody
haydenbleasel/files-sdk · packages/files-sdk/src/appwrite/index.ts:109
const isSupportedBody = (body: Body): boolean =>
// oxlint-disable-next-line sonarjs/expression-complexity -- a flat body-type guard; each instanceof check is a distinct supported Body shape, splitting would just scatter the union
isString(body) ||
body instanceof Uint8Array ||
body instanceof ArrayBuffer ||
ArrayBuffer.isView(body) ||
body instanceof Blob ||
body instanceof ReadableStream;
// `InputFile.fromBuffer` has no streaming form, so streamed bodies must be
// drained up-front. Other Body shapes already arrive as `Uint8Array` from
// the shared helper.
const toInputFile = async (
body: Body,
filename: string
): Promise<InputFile> => {
if (!isSupportedBody(body)) {
throw new FilesError(