file.d.ts 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. // Based on https://github.com/octet-stream/form-data/blob/2d0f0dc371517444ce1f22cdde13f51995d0953a/lib/File.ts (MIT)
  2. /// <reference types="node" />
  3. import { Blob } from 'buffer'
  4. export interface BlobPropertyBag {
  5. type?: string
  6. endings?: 'native' | 'transparent'
  7. }
  8. export interface FilePropertyBag extends BlobPropertyBag {
  9. /**
  10. * 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.
  11. */
  12. lastModified?: number
  13. }
  14. export declare class File extends Blob {
  15. /**
  16. * Creates a new File instance.
  17. *
  18. * @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).
  19. * @param fileName The name of the file.
  20. * @param options An options object containing optional attributes for the file.
  21. */
  22. constructor(fileBits: ReadonlyArray<string | NodeJS.ArrayBufferView | Blob>, fileName: string, options?: FilePropertyBag)
  23. /**
  24. * Name of the file referenced by the File object.
  25. */
  26. readonly name: string
  27. /**
  28. * 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.
  29. */
  30. readonly lastModified: number
  31. readonly [Symbol.toStringTag]: string
  32. }