JS Built-ins
Filebeginner

File β€” type option

πŸ“– Usage Example
const f = new File(['hi'], 'test.txt')
f.size  // β†’ 2

size returns the number of bytes in the file content.

File MIME Type

Pass { type } as the third argument to set the MIME type, just like Blob.

Challenge: Verify that new File(['x'], 'f.txt', { type: 'text/plain' }).type === 'text/plain'.

πŸ’‘ Hints (1)
  • β€’ File accepts the same options as Blob, including type.