FileAPI.idl (2873B)
1 // GENERATED CONTENT - DO NOT EDIT 2 // Content was automatically extracted by Reffy into webref 3 // (https://github.com/w3c/webref) 4 // Source: File API (https://w3c.github.io/FileAPI/) 5 6 [Exposed=(Window,Worker), Serializable] 7 interface Blob { 8 constructor(optional sequence<BlobPart> blobParts, 9 optional BlobPropertyBag options = {}); 10 11 readonly attribute unsigned long long size; 12 readonly attribute DOMString type; 13 14 // slice Blob into byte-ranged chunks 15 Blob slice(optional [Clamp] long long start, 16 optional [Clamp] long long end, 17 optional DOMString contentType); 18 19 // read from the Blob. 20 [NewObject] ReadableStream stream(); 21 [NewObject] Promise<USVString> text(); 22 [NewObject] Promise<ArrayBuffer> arrayBuffer(); 23 [NewObject] Promise<Uint8Array> bytes(); 24 }; 25 26 enum EndingType { "transparent", "native" }; 27 28 dictionary BlobPropertyBag { 29 DOMString type = ""; 30 EndingType endings = "transparent"; 31 }; 32 33 typedef (BufferSource or Blob or USVString) BlobPart; 34 35 [Exposed=(Window,Worker), Serializable] 36 interface File : Blob { 37 constructor(sequence<BlobPart> fileBits, 38 USVString fileName, 39 optional FilePropertyBag options = {}); 40 readonly attribute DOMString name; 41 readonly attribute long long lastModified; 42 }; 43 44 dictionary FilePropertyBag : BlobPropertyBag { 45 long long lastModified; 46 }; 47 48 [Exposed=(Window,Worker), Serializable] 49 interface FileList { 50 getter File? item(unsigned long index); 51 readonly attribute unsigned long length; 52 }; 53 54 [Exposed=(Window,Worker)] 55 interface FileReader: EventTarget { 56 constructor(); 57 // async read methods 58 undefined readAsArrayBuffer(Blob blob); 59 undefined readAsBinaryString(Blob blob); 60 undefined readAsText(Blob blob, optional DOMString encoding); 61 undefined readAsDataURL(Blob blob); 62 63 undefined abort(); 64 65 // states 66 const unsigned short EMPTY = 0; 67 const unsigned short LOADING = 1; 68 const unsigned short DONE = 2; 69 70 readonly attribute unsigned short readyState; 71 72 // File or Blob data 73 readonly attribute (DOMString or ArrayBuffer)? result; 74 75 readonly attribute DOMException? error; 76 77 // event handler content attributes 78 attribute EventHandler onloadstart; 79 attribute EventHandler onprogress; 80 attribute EventHandler onload; 81 attribute EventHandler onabort; 82 attribute EventHandler onerror; 83 attribute EventHandler onloadend; 84 }; 85 86 [Exposed=(DedicatedWorker,SharedWorker)] 87 interface FileReaderSync { 88 constructor(); 89 // Synchronously return strings 90 91 ArrayBuffer readAsArrayBuffer(Blob blob); 92 DOMString readAsBinaryString(Blob blob); 93 DOMString readAsText(Blob blob, optional DOMString encoding); 94 DOMString readAsDataURL(Blob blob); 95 }; 96 97 [Exposed=(Window,DedicatedWorker,SharedWorker)] 98 partial interface URL { 99 static DOMString createObjectURL((Blob or MediaSource) obj); 100 static undefined revokeObjectURL(DOMString url); 101 };