Blob.webidl (1499B)
1 /* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 2 /* This Source Code Form is subject to the terms of the Mozilla Public 3 * License, v. 2.0. If a copy of the MPL was not distributed with this file, 4 * You can obtain one at http://mozilla.org/MPL/2.0/. 5 * 6 * The origin of this IDL file is 7 * https://w3c.github.io/FileAPI/#blob 8 * 9 * Copyright © 2012 W3C® (MIT, ERCIM, Keio), All Rights Reserved. W3C 10 * liability, trademark and document use rules apply. 11 */ 12 13 typedef (BufferSource or Blob or UTF8String) BlobPart; 14 15 [Exposed=(Window,Worker)] 16 interface Blob { 17 [Throws] 18 constructor(optional sequence<BlobPart> blobParts, 19 optional BlobPropertyBag options = {}); 20 21 [GetterThrows] 22 readonly attribute unsigned long long size; 23 24 readonly attribute DOMString type; 25 26 //slice Blob into byte-ranged chunks 27 28 [Throws] 29 Blob slice(optional [Clamp] long long start, 30 optional [Clamp] long long end, 31 optional DOMString contentType); 32 33 // read from the Blob. 34 [NewObject, Throws] ReadableStream stream(); 35 [NewObject] Promise<USVString> text(); 36 [NewObject] Promise<ArrayBuffer> arrayBuffer(); 37 [NewObject] Promise<Uint8Array> bytes(); 38 }; 39 40 enum EndingType { "transparent", "native" }; 41 42 dictionary BlobPropertyBag { 43 DOMString type = ""; 44 EndingType endings = "transparent"; 45 }; 46 47 partial interface Blob { 48 // This returns the type of BlobImpl used for this Blob. 49 [ChromeOnly] 50 readonly attribute DOMString blobImplType; 51 };