Skip to main content

createObjectURL

method URL.createObjectURL
unstable
Jump to headingURL.createObjectURL(blob: NodeBlob): string

Creates a 'blob:nodedata:...' URL string that represents the given Blob object and can be used to retrieve the Blob later.

import {
  Blob,
  resolveObjectURL,
} from 'node:buffer';

const blob = new Blob(['hello']);
const id = URL.createObjectURL(blob);

// later...

const otherBlob = resolveObjectURL(id);
console.log(otherBlob.size);

The data stored by the registered Blob will be retained in memory until URL.revokeObjectURL() is called to remove it.

Blob objects are registered within the current thread. If using Worker Threads, Blob objects registered within one Worker will not be available to other workers or the main thread.

Parameters Jump to heading

Jump to headingblob: NodeBlob

Return Type Jump to heading

string
Back to top