slice method
Returns a new Blob object with bytes ranging from its optional start parameter up to but not including its optional end parameter.
![]() |
Syntax
var retVal = Blob.slice(start, end, contentType);Parameters
- start [in, optional]
-
Type: signed long long
The optional
startparameter is a value for the start point of aslicecall, and is treated as a byte-order position, with position 0 representing the first byte. Ifstartis negative, it is treated aslength+start, wherelengthis the length of the file (this allows byte selection starting from the end of the file). - end [in, optional]
-
Type: signed long long
The optional
endparameter is a value for the end point of aslicecall. The returned slice of data is up to but does not include theendbyte. Ifendis omitted, slice selects all bytes from thestartposition to the end of the file. Ifendis negative, it is treated aslength+end, wherelengthis the length of the file (this allows byte selection starting from the end of the file). - contentType [in, optional]
-
Type: DOMString
The optional
contentTypeparameter is used to set a value (identical to one that is set with the HTTP/1.1 Content-Type header) on the Blob returned by theslicecall. - retVal [out, retval]
-
Type: Blob
Remarks
The slice method returns a new Blob object with bytes ranging from the optional start parameter up to but not including the optional end parameter, and with a type attribute that is the value of the optional contentType parameter.
If it is not possible to obtain the object in the range specified, your application should throw the NotSupportedError exception.
For a code sample of the slice method, see Blob.
See also
