Javascript: BlobBuilder polyfill

The BlobBuilder interface provides an easy way to construct Blob objects. Just create a BlobBuilder and append chunks of data to it by calling the append() method. When you’re done building your blob, call getBlob() to retrieve a Blob containing the data you sent into the blob builder.

This feature is obsolete. Although it may still work in some browsers, its use is discouraged since it could be removed at any time. Try to avoid using it.


 * @author
 * @copyright 2019
class _BlobBuilder{     
    constructor() {
        this.blob = new Blob()
    append(data, endings){
        endings = endings || "transparent";
            this.blob = new Blob([data],{endings:endings})
            this.blob = new Blob([this.blob,data],{endings:endings})
            this.blob.type = contentType
        return this.blob;
    getFile(name, contentType){
            return new File(this.blob, name,{type: contentType})
        return new File(this.blob, name)

if("undefined" == typeof MozBlobBuilder && "undefined" == typeof WebKitBlobBuilder &&  "undefined" == typeof MSBlobBuilder)
    WebKitBlobBuilder = _BlobBuilder; 
    BlobBuilder = BlobBuilder || WebKitBlobBuilder || MozBlobBuilder || MSBlobBuilder;
if("undefined" == typeof BlobBuilder)
    BlobBuilder = _BlobBuilder;  

Download source code

Recent search terms:

  • blobbuilder polyfill

1 Comment

Leave a Reply