mozilla
Vos résultats de recherche

    BlobBuilder

    Nos bénévoles n'ont pas encore traduit cet article en Français. Aidez-nous à réaliser cette tâche !

    Obsolete
    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.

    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.

    Note: The BlobBuilder interface has been deprecated in favor of the newly introduced Blob constructor.

    Method overview

    void append(in ArrayBuffer data);
    void append(in Blob data);
    void append(in String data, [optional] in String endings);
    Blob getBlob([optional] in DOMString contentType);
    File getFile(in DOMString name, [optional] in DOMString contentType);

    Methods

    append()

    Appends the contents of the specified JavaScript object to the Blob being built. If the value you specify isn't a Blob, ArrayBuffer, or String, the value is coerced to a string before being appended to the blob.

    void append(
      in ArrayBuffer data
    );
    
    void append(
      in Blob data
    );
    
    
    void append(
      in String data,
      [optional] in String endings
    );
    
    Parameters
    data
    The data to append to the Blob being constructed.
    endings
    Specifies how strings containing \n are to be written out. This can be "transparent" (endings unchanged) or "native" (endings changed to match host OS filesystem convention). The default value is "transparent".

    getBlob()

    Returns the Blob object that has been constructed using the data passed through calls to append().

    Blob getBlob(
      in DOMString contentType Optional
    );
    
    Parameters
    contentType Optional
    The MIME type of the data to be returned in the Blob. This will be the value of the Blob object's type property.
    Return value

    A Blob object containing all of the data passed to any calls to append() made since the BlobBuilder was created. This also resets the BlobBuilder so that the next call to append() is starting a new, empty blob.

    getFile()

    Returns a File object.

    File getFile(
      in DOMString name,
      [optional] in DOMString contentType
    ); 
    
    Parameters
    name
    The file name.
    contentType Optional
    The MIME type of the data to be returned in the File. This will be the value of the File object's type property.
    Return value

    A File object.

    Browser compatibility

    Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari
    Basic support 8
    As WebKitBlobBuilder
    Not supported Gecko 18.0 10
    As MSBlobBuilder
    Not supported Not supported
    getfile() Not supported Not supported Not supported Not supported Not supported
    Feature Android Firefox Mobile (Gecko) IE Mobile Opera Mobile Safari Mobile
    Basic support 3
    As WebKitBlobBuilder
    Not supported Gecko 18.0 Not supported Not supported Not supported
    getfile() Not supported Not supported Not supported Not supported Not supported

    Notes on BlobBuilder deprecation

    • Starting in Firefox 14, using MozBlobBuilder will show a warning message in Web Console that the use of MozBlobBuilder is deprecated and use Blob constructor instead.
    • WebKit has deprecated WebKitBlobBuilder and has made its support configurable. Currently Safari disables the feature in Nightly, so it will never likely to ship in the final version. On the other hand, Chrome, which has supported it since Chrome 8, still enables the feature. So Chrome might continue to support the feature. (See this WebKit changeset for details).

    See also

    Étiquettes et contributeurs liés au document

    Contributors to this page: Sheppy, fscholz, ebidel, evilpie, myakura, teoli, Sephr, FredB, gert, kscarfone
    Dernière mise à jour par : teoli,