Back to Content

URL: createObjectURL() static method

files/en-us/web/api/url/createobjecturl_static/index.md

latest1.7 KB
Original Source

{{APIRef("File API")}} {{AvailableInWorkers("window_and_worker_except_service")}}

The createObjectURL() static method of the {{domxref("URL")}} interface creates a string containing a blob URL pointing to the object given in the parameter.

For more information, see blob URLs.

To release an object URL, call {{domxref("URL.revokeObjectURL_static", "revokeObjectURL()")}}.

[!NOTE] This feature is not available in Service Workers due to its potential to create memory leaks.

Syntax

js-nolint
URL.createObjectURL(object)

Parameters

  • object
    • : A {{domxref("Blob")}} (such as a {{domxref("File")}}) or {{domxref("MediaSource")}} object to create an object URL for.

Return value

A string containing an object URL that can be used to reference the contents of the specified source object.

Examples

See Using object URLs to display images.

Specifications

{{Specifications}}

Browser compatibility

{{Compat}}

See also