Module org.htmlunit

Class Blob

java.lang.Object
org.htmlunit.corejs.javascript.SlotMapOwner<org.htmlunit.corejs.javascript.Scriptable>
org.htmlunit.corejs.javascript.ScriptableObject
org.htmlunit.javascript.HtmlUnitScriptable
org.htmlunit.javascript.host.file.Blob
All Implemented Interfaces:
Serializable, Cloneable, org.htmlunit.corejs.javascript.ConstProperties<org.htmlunit.corejs.javascript.Scriptable>, org.htmlunit.corejs.javascript.debug.DebuggableObject, org.htmlunit.corejs.javascript.PropHolder<org.htmlunit.corejs.javascript.Scriptable>, org.htmlunit.corejs.javascript.Scriptable, org.htmlunit.corejs.javascript.SymbolScriptable
Direct Known Subclasses:
File

public class Blob extends HtmlUnitScriptable
A JavaScript object for Blob.
Author:
Ahmed Ashour, Ronald Brill, Lai Quang Duong
See Also:
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    protected static class 
    The backend used for saving the blob.
    protected static class 
    Implementation of the Blob.Backend that stores the bytes in memory.

    Nested classes/interfaces inherited from class org.htmlunit.corejs.javascript.ScriptableObject

    org.htmlunit.corejs.javascript.ScriptableObject.DescriptorInfo, org.htmlunit.corejs.javascript.ScriptableObject.KeyComparator, org.htmlunit.corejs.javascript.ScriptableObject.LambdaGetterFunction, org.htmlunit.corejs.javascript.ScriptableObject.LambdaSetterFunction
  • Field Summary

    Fields inherited from class org.htmlunit.corejs.javascript.ScriptableObject

    CONST, DONTENUM, EMPTY, PERMANENT, READONLY, UNINITIALIZED_CONST

    Fields inherited from class org.htmlunit.corejs.javascript.SlotMapOwner

    isSealed

    Fields inherited from interface org.htmlunit.corejs.javascript.Scriptable

    NOT_FOUND
  • Constructor Summary

    Constructors
    Constructor
    Description
    Creates an instance.
    Blob(byte[] bytes, String contentType)
    Ctor.
  • Method Summary

    Modifier and Type
    Method
    Description
    org.htmlunit.corejs.javascript.NativePromise
     
    protected static String
    extractFileTypeOrDefault(org.htmlunit.corejs.javascript.ScriptableObject properties)
     
    protected static long
    extractLastModifiedOrDefault(org.htmlunit.corejs.javascript.ScriptableObject properties)
     
    void
    fillRequest(WebRequest webRequest)
    Sets the specified request with the parameters in this FormData.
    protected Blob.Backend
     
    byte[]
     
    getKeyDataPair(String name, String fileName)
    Delegates the KeyDataPair construction to the backend.
    long
    Returns the size property.
    Returns the type property.
    void
    jsConstructor(org.htmlunit.corejs.javascript.NativeArray fileBits, org.htmlunit.corejs.javascript.ScriptableObject properties)
    Creates an instance.
    protected void
     
    slice(Object start, Object end, Object contentType)
     
     
    org.htmlunit.corejs.javascript.NativePromise
     

    Methods inherited from class org.htmlunit.corejs.javascript.ScriptableObject

    applyDescriptorToAttributeBitset, avoidObjectDetection, buildDataDescriptor, callMethod, callMethod, checkNotSealed, checkPropertyChangeForSlot, checkPropertyChangeForSlot, checkPropertyDefinition, checkPropertyDefinition, checkSlotRemoval, defineBuiltinProperty, defineBuiltinProperty, defineBuiltInProperty, defineBuiltInProperty, defineBuiltInProperty, defineBuiltInProperty, defineClass, defineClass, defineClass, defineConst, defineConstProperty, defineFunctionProperties, defineOwnProperties, defineOwnProperty, defineOwnProperty, defineOwnProperty, defineProperty, defineProperty, defineProperty, defineProperty, defineProperty, defineProperty, defineProperty, defineProperty, defineProperty, defineProperty, delete, delete, delete, deleteProperty, deleteProperty, deleteProperty, ensureScriptable, ensureScriptableObject, ensureScriptableObjectButNotSymbol, ensureSymbolScriptable, ensureType, get, get, getAllIds, getAncestor, getArrayPrototype, getClassPrototype, getClassPrototype, getDefaultValue, getExternalArrayData, getExternalArrayLength, getFunctionPrototype, getGeneratorFunctionPrototype, getGetterOrSetter, getGetterOrSetter, getObjectPrototype, getOwnPropertyDescriptor, getParentScope, getProperty, getProperty, getProperty, getProperty, getProperty, getPropertyIds, getPrototype, getSuperProperty, getSuperProperty, getSuperProperty, getThis, getTopLevelScope, getTopScopeValue, getTypedProperty, getTypedProperty, getTypeOf, hasProperty, hasProperty, hasProperty, hasProperty, isAccessorDescriptor, isAccessorDescriptor, isConst, isDataDescriptor, isEmpty, isExtensible, isFalse, isGenericDescriptor, isGenericDescriptor, isGetterOrSetter, isGetterOrSetter, isTrue, preventExtensions, put, put, putConst, putConstProperty, putConstProperty, putOwnProperty, putOwnProperty, putOwnProperty, putProperty, putProperty, putProperty, putProperty, putSuperProperty, putSuperProperty, putSuperProperty, querySlot, redefineProperty, redefineProperty, sameValue, sealObject, setCommonDescriptorProperties, setExternalArrayData, setGetterOrSetter, setParentScope, setPrototype, size

    Methods inherited from class org.htmlunit.corejs.javascript.SlotMapOwner

    associateValue, checkNotSealed, copyAssociatedValue, createSlotMap, defineProperty, defineProperty, get, getAssociatedValue, getAttributes, getAttributes, getAttributes, getAttributes, getAttributes, getIds, has, has, isSealed, readMaps, setAttributes, setAttributes, setAttributes, setAttributes, setAttributes, writeMaps

    Methods inherited from class java.lang.Object

    equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface org.htmlunit.corejs.javascript.Scriptable

    get, getIds, has, has

    Methods inherited from interface org.htmlunit.corejs.javascript.SymbolScriptable

    get, has
  • Constructor Details

    • Blob

      public Blob()
      Creates an instance.
    • Blob

      public Blob(byte[] bytes, String contentType)
      Ctor.
      Parameters:
      bytes - the bytes
      contentType - the content type
  • Method Details

    • extractFileTypeOrDefault

      protected static String extractFileTypeOrDefault(org.htmlunit.corejs.javascript.ScriptableObject properties)
    • extractLastModifiedOrDefault

      protected static long extractLastModifiedOrDefault(org.htmlunit.corejs.javascript.ScriptableObject properties)
    • jsConstructor

      public void jsConstructor(org.htmlunit.corejs.javascript.NativeArray fileBits, org.htmlunit.corejs.javascript.ScriptableObject properties)
      Creates an instance.
      Parameters:
      fileBits - the bits
      properties - the properties
    • getSize

      public long getSize()
      Returns the size property.
      Returns:
      the size property
    • getType

      public String getType()
      Returns the type property.
      Returns:
      the type property
    • arrayBuffer

      public org.htmlunit.corejs.javascript.NativePromise arrayBuffer()
      Returns:
      a Promise that resolves with an ArrayBuffer containing the data in binary form.
    • slice

      public Blob slice(Object start, Object end, Object contentType)
      Parameters:
      start - An index into the Blob indicating the first byte to include in the new Blob. If you specify a negative value, it's treated as an offset from the end of the Blob toward the beginning. For example, -10 would be the 10th from last byte in the Blob. The default value is 0. If you specify a value for start that is larger than the size of the source Blob, the returned Blob has size 0 and contains no data.
      end - An index into the Blob indicating the first byte that will not be included in the new Blob (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 the Blob toward the beginning. For example, -10 would be the 10th from last byte in the Blob. The default value is size.
      contentType - The content type to assign to the new Blob; this will be the value of its type property. The default value is an empty string.
      Returns:
      a new Blob object which contains data from a subset of the blob on which it's called.
    • stream

      public ReadableStream stream()
      Returns:
      a ReadableStream which, upon reading, returns the contents of the Blob.
    • text

      public org.htmlunit.corejs.javascript.NativePromise text()
      Returns:
      a Promise that resolves with a string containing the contents of the blob, interpreted as UTF-8.
    • getBytes

      public byte[] getBytes()
      Returns:
      the bytes of this blob
    • fillRequest

      public void fillRequest(WebRequest webRequest)
      Sets the specified request with the parameters in this FormData.
      Parameters:
      webRequest - the web request to fill
    • getKeyDataPair

      public KeyDataPair getKeyDataPair(String name, String fileName)
      Delegates the KeyDataPair construction to the backend.
      Parameters:
      name - the name
      fileName - the filename
      Returns:
      the constructed KeyDataPair
    • getBackend

      protected Blob.Backend getBackend()
    • setBackend

      protected void setBackend(Blob.Backend backend)