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
A JavaScript object for
Blob.- Author:
- Ahmed Ashour, Ronald Brill, Lai Quang Duong
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static classThe backend used for saving the blob.protected static classImplementation of theBlob.Backendthat 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_CONSTFields inherited from class org.htmlunit.corejs.javascript.SlotMapOwner
isSealedFields inherited from interface org.htmlunit.corejs.javascript.Scriptable
NOT_FOUND -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionorg.htmlunit.corejs.javascript.NativePromiseprotected static StringextractFileTypeOrDefault(org.htmlunit.corejs.javascript.ScriptableObject properties) protected static longextractLastModifiedOrDefault(org.htmlunit.corejs.javascript.ScriptableObject properties) voidfillRequest(WebRequest webRequest) Sets the specified request with the parameters in thisFormData.protected Blob.Backendbyte[]getBytes()getKeyDataPair(String name, String fileName) Delegates the KeyDataPair construction to the backend.longgetSize()Returns thesizeproperty.getType()Returns thetypeproperty.voidjsConstructor(org.htmlunit.corejs.javascript.NativeArray fileBits, org.htmlunit.corejs.javascript.ScriptableObject properties) Creates an instance.protected voidsetBackend(Blob.Backend backend) stream()org.htmlunit.corejs.javascript.NativePromisetext()Methods inherited from class org.htmlunit.javascript.HtmlUnitScriptable
clone, equivalentValues, get, getBrowserVersion, getClassName, getDefaultValue, getDomNodeOrDie, getDomNodeOrNull, getPrototype, getScriptableFor, getWindow, getWindow, getWindowOrWorkerGlobalScope, getWithPreemption, has, hasInstance, makeScriptableFor, put, setClassName, setDomNode, setDomNode, setupPromise, setupRejectedPromiseMethods 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, sizeMethods 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, writeMapsMethods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.htmlunit.corejs.javascript.Scriptable
get, getIds, has, hasMethods inherited from interface org.htmlunit.corejs.javascript.SymbolScriptable
get, has
-
Constructor Details
-
Blob
public Blob()Creates an instance. -
Blob
Ctor.- Parameters:
bytes- the bytescontentType- 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 bitsproperties- the properties
-
getSize
public long getSize()Returns thesizeproperty.- Returns:
- the
sizeproperty
-
getType
Returns thetypeproperty.- Returns:
- the
typeproperty
-
arrayBuffer
public org.htmlunit.corejs.javascript.NativePromise arrayBuffer()- Returns:
- a Promise that resolves with an ArrayBuffer containing the data in binary form.
-
slice
- 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
- 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
Sets the specified request with the parameters in thisFormData.- Parameters:
webRequest- the web request to fill
-
getKeyDataPair
Delegates the KeyDataPair construction to the backend.- Parameters:
name- the namefileName- the filename- Returns:
- the constructed
KeyDataPair
-
getBackend
-
setBackend
-