MCPcopy Create free account
hub / github.com/Effect-TS/effect / file

Function file

packages/effect/src/unstable/http/HttpBody.ts:511–529  ·  view source on GitHub ↗
(
  path: string,
  options?: {
    readonly bytesToRead?: FileSystem.SizeInput | undefined
    readonly chunkSize?: FileSystem.SizeInput | undefined
    readonly offset?: FileSystem.SizeInput | undefined
    readonly contentType?: string | undefined
  }
)

Source from the content-addressed store, hash-verified

509 * @since 4.0.0
510 */
511export const file = (
512 path: string,
513 options?: {
514 readonly bytesToRead?: FileSystem.SizeInput | undefined
515 readonly chunkSize?: FileSystem.SizeInput | undefined
516 readonly offset?: FileSystem.SizeInput | undefined
517 readonly contentType?: string | undefined
518 }
519): Effect.Effect<Stream, PlatformError.PlatformError, FileSystem.FileSystem> =>
520 Effect.flatMap(
521 FileSystem.FileSystem,
522 (fs) =>
523 Effect.map(fs.stat(path), (info) =>
524 stream(
525 fs.stream(path, options),
526 options?.contentType,
527 fileContentLength(info.size, options)
528 ))
529 )
530
531/**
532 * Creates a streaming HTTP body for a file path using already-known file information.

Callers

nothing calls this directly

Calls 5

fileContentLengthFunction · 0.85
streamFunction · 0.70
streamMethod · 0.65
mapMethod · 0.45
statMethod · 0.45

Tested by

no test coverage detected