Skip to content

armgit / papra

Public Imported from GitHub
0

The minimalistic document archiving platform.

468 B
Raw Blame
import type { Readable } from 'node:stream';
import type { ReadableStream } from 'node:stream/web';

export async function collectStreamToFile({
  fileStream,
  fileName,
  mimeType,
}: {
  fileStream: ReadableStream | Readable;
  fileName: string;
  mimeType: string;
}): Promise<{ file: File }> {
  const response = new Response(fileStream);
  const blob = await response.blob();

  const file = new File([blob], fileName, { type: mimeType });

  return { file };
}