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

Class FileImpl

packages/platform/node/src/NodeMultipart.ts:136–169  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

134}
135
136class FileImpl extends PartBase implements Multipart.File {
137 readonly _tag = "File"
138 readonly key: string
139 readonly name: string
140 readonly contentType: string
141 readonly content: Stream.Stream<Uint8Array, Multipart.MultipartError>
142 readonly contentEffect: Effect.Effect<Uint8Array, Multipart.MultipartError>
143 readonly file: MP.FileStream
144
145 constructor(file: MP.FileStream) {
146 super()
147 this.file = file
148 this.key = file.info.name
149 this.name = file.filename ?? file.info.name
150 this.contentType = file.info.contentType
151 this.content = NodeStream.fromReadable({
152 evaluate: () => file,
153 onError: (cause) => Multipart.MultipartError.fromReason("InternalError", cause)
154 })
155 this.contentEffect = NodeStream.toUint8Array(() => file, {
156 onError: (cause) => Multipart.MultipartError.fromReason("InternalError", cause)
157 })
158 }
159
160 toJSON(): unknown {
161 return {
162 _id: "@effect/platform/Multipart/Part",
163 _tag: "File",
164 key: this.key,
165 name: this.name,
166 contentType: this.contentType
167 }
168 }
169}
170
171function convertError(cause: MultipartParser.MultipartError): Multipart.MultipartError {
172 switch (cause._tag) {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected