AwaitedDOM / File
File
interface provides information about files and allows JavaScript in a web page to access their content.File
objects are generally retrieved from a FileList
object returned as a result of a user selecting files using the <input>
element, from a drag and drop operation's DataTransfer
object, or from the mozGetAsFile()
API on an HTMLCanvasElement
.File
object is a specific kind of a Blob
, and can be used in any context that a Blob can. In particular, FileReader
, URL.createObjectURL()
, createImageBitmap()
, and XMLHttpRequest.send()
accept both Blob
s and File
s.Properties
.lastModified W3C {#lastModified}
Returns the last modified time of the file, in millisecond since the UNIX epoch (January 1st, 1970 at Midnight).
Type: Promise<number>
.name W3C {#name}
Returns the name of the file referenced by the File
object.
Type: Promise<string>
.size W3C {#size}
The size, in bytes, of the data contained in the Blob
object.
Type: Promise<number>
.type W3C {#type}
A string indicating the MIME type of the data contained in the Blob
. If the type is unknown, this string is empty.
Type: Promise<string>
Methods
.arrayBuffer*()* W3C {#arrayBuffer}
Returns a promise that resolves with an ArrayBuffer
containing the entire contents of the Blob
as binary data.
Returns: Promise<ArrayBuffer>
.slice*(start?, end?, contentType?)* W3C {#slice}
Returns a new Blob
object containing the data in the specified range of bytes of the blob on which it's called.
Arguments:
start
number
. An index into theBlob
indicating the first byte to include in the newBlob
. If you specify a negative value, it's treated as an offset from the end of theBlob
toward the beginning. For example, -10 would be the 10th from last byte in theBlob
. The default value is 0. If you specify a value forstart
that is larger than the size of the sourceBlob
, the returnedBlob
has size 0 and contains no data.end
number
. An index into theBlob
indicating the first byte that will not be included in the newBlob
(i.e. the byte exactly at this index is not included). If you specify a negative value, it's treated as an offset from the end of theBlob
toward the beginning. For example, -10 would be the 10th from last byte in theBlob
. The default value issize
.contentType
string
. The content type to assign to the newBlob
; this will be the value of itstype
property. The default value is an empty string.
Returns: Promise<Blob>
.text*()* W3C {#text}
Returns a promise that resolves with a string
containing the entire contents of the Blob
interpreted as UTF-8 text.
Returns: Promise<string>
Unimplemented Specs
Methods
stream() |