diff options
Diffstat (limited to 'std/mime/multipart.ts')
-rw-r--r-- | std/mime/multipart.ts | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/std/mime/multipart.ts b/std/mime/multipart.ts index 26860e3de..d88ff3d13 100644 --- a/std/mime/multipart.ts +++ b/std/mime/multipart.ts @@ -8,13 +8,35 @@ type Writer = Deno.Writer; import { equal, findIndex, findLastIndex, hasPrefix } from "../bytes/mod.ts"; import { copyN } from "../io/ioutil.ts"; import { MultiReader } from "../io/readers.ts"; -import { FormFile } from "../multipart/formfile.ts"; import { extname } from "../path/mod.ts"; import { tempFile } from "../io/util.ts"; import { BufReader, BufWriter, UnexpectedEOFError } from "../io/bufio.ts"; import { encoder } from "../strings/mod.ts"; import { assertStrictEq } from "../testing/asserts.ts"; import { TextProtoReader } from "../textproto/mod.ts"; +import { hasOwnProperty } from "../util/has_own_property.ts"; + +/** FormFile object */ +export interface FormFile { + /** filename */ + filename: string; + /** content-type header value of file */ + type: string; + /** byte size of file */ + size: number; + /** in-memory content of file. Either content or tempfile is set */ + content?: Uint8Array; + /** temporal file path. + * Set if file size is bigger than specified max-memory size at reading form + * */ + tempfile?: string; +} + +/** Type guard for FormFile */ +// eslint-disable-next-line @typescript-eslint/no-explicit-any +export function isFormFile(x: any): x is FormFile { + return hasOwnProperty(x, "filename") && hasOwnProperty(x, "type"); +} function randomBoundary(): string { let boundary = "--------------------------"; |