tencent cloud

Feedback

WritableStream

Last updated: 2024-01-30 16:00:52
    The WritableStream API represents a writable stream or writable side. It is designed based on the standard Web API WritableStream.
    Note:
    A WritableStream object cannot be constructed directly. You can use TransformStream to construct a WritableStream object.

    Overview

    // Use TransformStream to construct a WritableStream object.
    const { writable } = new TransformStream();

    Attributes

    locked

    // writable.locked
    readonly locked: boolean;
    The locked attribute indicates whether the stream is locked.
    Note:
    A stream is locked in the following scenarios:
    The stream has no more than one activated writer. Before the writer calls the releaseLock() method, the stream is locked.
    The stream is in being piped. The stream is locked until the piping ends.

    highWaterMark

    // writable.highWaterMark
    readonly highWaterMark: number;
    The size of the writable buffer in bytes. Default value: 32K. Maximum value: 256K. If you enter a value greater than 256K, the value is changed to 256K automatically.

    Methods

    Note:
    Before you use any of the following methods, make sure that the stream is not locked. Otherwise, an exception is returned.

    getWriter

    writable.getWriter(): WritableStreamDefaultWriter;
    The getWriter() method creates a writer and locks the current stream until the writer calls the releaseLock() method. For more information about the returned values, see WritableStreamDefaultWriter.

    close

    writable.close(): Promise<void>;
    The close() method closes the current stream.

    abort

    writable.abort(reason?: string): Promise<string>;
    The abort() method stops the current stream.

    References

    Contact Us

    Contact our sales team or business advisors to help your business.

    Technical Support

    Open a ticket if you're looking for further assistance. Our Ticket is 7x24 avaliable.

    7x24 Phone Support