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

Class FileImpl

packages/platform-node-shared/src/internal/multipart.ts:83–114  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

81}
82
83class FileImpl extends PartBase implements Multipart.File {
84 readonly _tag = "File"
85 readonly key: string
86 readonly name: string
87 readonly contentType: string
88 readonly content: Stream.Stream<Uint8Array, Multipart.MultipartError>
89 readonly contentEffect: Effect.Effect<Uint8Array, Multipart.MultipartError>
90
91 constructor(readonly file: MP.FileStream) {
92 super()
93 this.key = file.info.name
94 this.name = file.filename ?? file.info.name
95 this.contentType = file.info.contentType
96 this.content = NodeStream.fromReadable(
97 () => file,
98 (cause) => new Multipart.MultipartError({ reason: "InternalError", cause })
99 )
100 this.contentEffect = NodeStream.toUint8Array(() => file, {
101 onFailure: (cause) => new Multipart.MultipartError({ reason: "InternalError", cause })
102 })
103 }
104
105 toJSON(): unknown {
106 return {
107 _id: "@effect/platform/Multipart/Part",
108 _tag: "File",
109 key: this.key,
110 name: this.name,
111 contentType: this.contentType
112 }
113 }
114}
115
116/** @internal */
117export const fileToReadable = (file: Multipart.File): Readable => (file as FileImpl).file

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…