• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1// Based on https://github.com/octet-stream/form-data/blob/2d0f0dc371517444ce1f22cdde13f51995d0953a/lib/File.ts (MIT)
2/// <reference types="node" />
3
4import { Blob } from 'buffer'
5
6export interface BlobPropertyBag {
7  type?: string
8  endings?: 'native' | 'transparent'
9}
10
11export interface FilePropertyBag extends BlobPropertyBag {
12  /**
13   * The last modified date of the file as the number of milliseconds since the Unix epoch (January 1, 1970 at midnight). Files without a known last modified date return the current date.
14   */
15  lastModified?: number
16}
17
18export declare class File extends Blob {
19  /**
20   * Creates a new File instance.
21   *
22   * @param fileBits An `Array` strings, or [`ArrayBuffer`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer), [`ArrayBufferView`](https://developer.mozilla.org/en-US/docs/Web/API/ArrayBufferView), [`Blob`](https://developer.mozilla.org/en-US/docs/Web/API/Blob) objects, or a mix of any of such objects, that will be put inside the [`File`](https://developer.mozilla.org/en-US/docs/Web/API/File).
23   * @param fileName The name of the file.
24   * @param options An options object containing optional attributes for the file.
25   */
26  constructor(fileBits: ReadonlyArray<string | NodeJS.ArrayBufferView | Blob>, fileName: string, options?: FilePropertyBag)
27
28  /**
29   * Name of the file referenced by the File object.
30   */
31  readonly name: string
32
33  /**
34   * The last modified date of the file as the number of milliseconds since the Unix epoch (January 1, 1970 at midnight). Files without a known last modified date return the current date.
35   */
36  readonly lastModified: number
37
38  readonly [Symbol.toStringTag]: string
39}
40