WritableStream
A WritableStream is the writable property of a TransformStream. On the Workers platform, WritableStream cannot be directly created using the WritableStream constructor.
A typical way to write to a WritableStream is to pipe a ReadableStream to it.
readableStream .pipeTo(writableStream) .then(() => console.log('All data successfully written!')) .catch(e => console.error('Something went wrong!', e));To write to a WritableStream directly, you must use its writer.
const writer = writableStream.getWriter();writer.write(data);Refer to the WritableStreamDefaultWriter documentation for further detail.
-
lockedboolean- A Boolean value to indicate if the writable stream is locked to a writer.
-
abort(reasonstringoptional): Promise<void>- Aborts the stream. This method returns a promise that fulfills with a response
undefined.reasonis an optional human-readable string indicating the reason for cancellation.reasonwill be passed to the underlying sink’s abort algorithm. If this writable stream is one side of a TransformStream, then its abort algorithm causes the transform’s readable side to become errored withreason.
- Aborts the stream. This method returns a promise that fulfills with a response
-
getWriter(): WritableStreamDefaultWriter- Gets an instance of
WritableStreamDefaultWriterand locks theWritableStreamto that writer instance.
- Gets an instance of
Was this helpful?
- Resources
- API
- New to Cloudflare?
- Directory
- Sponsorships
- Open Source
- Support
- Help Center
- System Status
- Compliance
- GDPR
- Company
- cloudflare.com
- Our team
- Careers
- © 2025 Cloudflare, Inc.
- Privacy Policy
- Terms of Use
- Report Security Issues
- Trademark