Options
All
  • Public
  • Public/Protected
  • All
Menu

Class GridFSBucketWriteStream

A writable stream that enables you to write buffers to GridFS.

Do not instantiate this class directly. Use openUploadStream() instead.

Hierarchy

  • Writable
    • GridFSBucketWriteStream

Index

Constructors

constructor

Events

Static Readonly CLOSE

CLOSE: "close" = 'close'

Static Readonly ERROR

ERROR: "error" = 'error'

Static Readonly FINISH

FINISH: "finish" = 'finish'

end() was called and the write stream successfully wrote the file metadata and all the chunks to MongoDB.

Properties

bucket

bucket: GridFSBucket

bufToStore

bufToStore: Buffer

chunkSizeBytes

chunkSizeBytes: number

chunks

destroyed

destroyed: boolean

done

done: boolean

filename

filename: string

files

id

length

length: number

n

n: number

options

pos

pos: number

state

state: { aborted: boolean; errored: boolean; outstandingRequests: number; streamEnd: boolean }

Type declaration

  • aborted: boolean
  • errored: boolean
  • outstandingRequests: number
  • streamEnd: boolean

Readonly writable

writable: boolean

Readonly writableCorked

writableCorked: number

Readonly writableEnded

writableEnded: boolean

Readonly writableFinished

writableFinished: boolean

Readonly writableHighWaterMark

writableHighWaterMark: number

Readonly writableLength

writableLength: number

Readonly writableObjectMode

writableObjectMode: boolean

Optional writeConcern

writeConcern: WriteConcern

Static Readonly captureRejectionSymbol

captureRejectionSymbol: typeof captureRejectionSymbol

Static captureRejections

captureRejections: boolean

Sets or gets the default captureRejection value for all emitters.

Static defaultMaxListeners

defaultMaxListeners: number

Static Readonly errorMonitor

errorMonitor: typeof errorMonitor

This symbol shall be used to install a listener for only monitoring 'error' events. Listeners installed using this symbol are called before the regular 'error' listeners are called.

Installing a listener using this symbol does not change the behavior once an 'error' event is emitted, therefore the process will still crash if no regular 'error' listener is installed.

Methods

Optional _construct

  • _construct(callback: (error?: null | Error) => void): void
  • Parameters

    • callback: (error?: null | Error) => void
        • (error?: null | Error): void
        • Parameters

          • Optional error: null | Error

          Returns void

    Returns void

_destroy

  • _destroy(error: null | Error, callback: (error?: null | Error) => void): void
  • Parameters

    • error: null | Error
    • callback: (error?: null | Error) => void
        • (error?: null | Error): void
        • Parameters

          • Optional error: null | Error

          Returns void

    Returns void

_final

  • _final(callback: (error?: null | Error) => void): void
  • Parameters

    • callback: (error?: null | Error) => void
        • (error?: null | Error): void
        • Parameters

          • Optional error: null | Error

          Returns void

    Returns void

_write

  • _write(chunk: any, encoding: BufferEncoding, callback: (error?: null | Error) => void): void
  • Parameters

    • chunk: any
    • encoding: BufferEncoding
    • callback: (error?: null | Error) => void
        • (error?: null | Error): void
        • Parameters

          • Optional error: null | Error

          Returns void

    Returns void

Optional _writev

  • _writev(chunks: { chunk: any; encoding: BufferEncoding }[], callback: (error?: null | Error) => void): void
  • Parameters

    • chunks: { chunk: any; encoding: BufferEncoding }[]
    • callback: (error?: null | Error) => void
        • (error?: null | Error): void
        • Parameters

          • Optional error: null | Error

          Returns void

    Returns void

abort

  • abort(): Promise<void>
  • abort(callback: Callback<void>): void

addListener

  • Event emitter The defined events on documents including:

    1. close
    2. drain
    3. error
    4. finish
    5. pipe
    6. unpipe

    Parameters

    • event: "close"
    • listener: () => void
        • (): void
        • Returns void

    Returns GridFSBucketWriteStream

  • Parameters

    • event: "drain"
    • listener: () => void
        • (): void
        • Returns void

    Returns GridFSBucketWriteStream

  • Parameters

    • event: "error"
    • listener: (err: Error) => void
        • (err: Error): void
        • Parameters

          • err: Error

          Returns void

    Returns GridFSBucketWriteStream

  • Parameters

    • event: "finish"
    • listener: () => void
        • (): void
        • Returns void

    Returns GridFSBucketWriteStream

  • Parameters

    • event: "pipe"
    • listener: (src: Readable) => void
        • (src: Readable): void
        • Parameters

          • src: Readable

          Returns void

    Returns GridFSBucketWriteStream

  • Parameters

    • event: "unpipe"
    • listener: (src: Readable) => void
        • (src: Readable): void
        • Parameters

          • src: Readable

          Returns void

    Returns GridFSBucketWriteStream

  • Parameters

    • event: string | symbol
    • listener: (...args: any[]) => void
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns GridFSBucketWriteStream

cork

  • cork(): void
  • Returns void

destroy

  • destroy(error?: Error): void
  • Parameters

    • Optional error: Error

    Returns void

emit

  • emit(event: "close"): boolean
  • emit(event: "drain"): boolean
  • emit(event: "error", err: Error): boolean
  • emit(event: "finish"): boolean
  • emit(event: "pipe", src: Readable): boolean
  • emit(event: "unpipe", src: Readable): boolean
  • emit(event: string | symbol, ...args: any[]): boolean
  • Parameters

    • event: "close"

    Returns boolean

  • Parameters

    • event: "drain"

    Returns boolean

  • Parameters

    • event: "error"
    • err: Error

    Returns boolean

  • Parameters

    • event: "finish"

    Returns boolean

  • Parameters

    • event: "pipe"
    • src: Readable

    Returns boolean

  • Parameters

    • event: "unpipe"
    • src: Readable

    Returns boolean

  • Parameters

    • event: string | symbol
    • Rest ...args: any[]

    Returns boolean

end

  • end(): void
  • end(chunk: Buffer): void
  • end(callback: Callback<void | GridFSFile>): void
  • end(chunk: Buffer, callback: Callback<void | GridFSFile>): void
  • end(chunk: Buffer, encoding: BufferEncoding): void
  • end(chunk: Buffer, encoding: undefined | BufferEncoding, callback: Callback<void | GridFSFile>): void

eventNames

  • eventNames(): (string | symbol)[]
  • Returns (string | symbol)[]

getMaxListeners

  • getMaxListeners(): number
  • Returns number

listenerCount

  • listenerCount(event: string | symbol): number
  • Parameters

    • event: string | symbol

    Returns number

listeners

  • listeners(event: string | symbol): Function[]
  • Parameters

    • event: string | symbol

    Returns Function[]

off

  • Parameters

    • event: string | symbol
    • listener: (...args: any[]) => void
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns GridFSBucketWriteStream

on

  • Parameters

    • event: "close"
    • listener: () => void
        • (): void
        • Returns void

    Returns GridFSBucketWriteStream

  • Parameters

    • event: "drain"
    • listener: () => void
        • (): void
        • Returns void

    Returns GridFSBucketWriteStream

  • Parameters

    • event: "error"
    • listener: (err: Error) => void
        • (err: Error): void
        • Parameters

          • err: Error

          Returns void

    Returns GridFSBucketWriteStream

  • Parameters

    • event: "finish"
    • listener: () => void
        • (): void
        • Returns void

    Returns GridFSBucketWriteStream

  • Parameters

    • event: "pipe"
    • listener: (src: Readable) => void
        • (src: Readable): void
        • Parameters

          • src: Readable

          Returns void

    Returns GridFSBucketWriteStream

  • Parameters

    • event: "unpipe"
    • listener: (src: Readable) => void
        • (src: Readable): void
        • Parameters

          • src: Readable

          Returns void

    Returns GridFSBucketWriteStream

  • Parameters

    • event: string | symbol
    • listener: (...args: any[]) => void
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns GridFSBucketWriteStream

once

  • Parameters

    • event: "close"
    • listener: () => void
        • (): void
        • Returns void

    Returns GridFSBucketWriteStream

  • Parameters

    • event: "drain"
    • listener: () => void
        • (): void
        • Returns void

    Returns GridFSBucketWriteStream

  • Parameters

    • event: "error"
    • listener: (err: Error) => void
        • (err: Error): void
        • Parameters

          • err: Error

          Returns void

    Returns GridFSBucketWriteStream

  • Parameters

    • event: "finish"
    • listener: () => void
        • (): void
        • Returns void

    Returns GridFSBucketWriteStream

  • Parameters

    • event: "pipe"
    • listener: (src: Readable) => void
        • (src: Readable): void
        • Parameters

          • src: Readable

          Returns void

    Returns GridFSBucketWriteStream

  • Parameters

    • event: "unpipe"
    • listener: (src: Readable) => void
        • (src: Readable): void
        • Parameters

          • src: Readable

          Returns void

    Returns GridFSBucketWriteStream

  • Parameters

    • event: string | symbol
    • listener: (...args: any[]) => void
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns GridFSBucketWriteStream

pipe

  • pipe<T>(destination: T, options?: { end?: boolean }): T
  • Type parameters

    • T: WritableStream<T>

    Parameters

    • destination: T
    • Optional options: { end?: boolean }
      • Optional end?: boolean

    Returns T

prependListener

  • Parameters

    • event: "close"
    • listener: () => void
        • (): void
        • Returns void

    Returns GridFSBucketWriteStream

  • Parameters

    • event: "drain"
    • listener: () => void
        • (): void
        • Returns void

    Returns GridFSBucketWriteStream

  • Parameters

    • event: "error"
    • listener: (err: Error) => void
        • (err: Error): void
        • Parameters

          • err: Error

          Returns void

    Returns GridFSBucketWriteStream

  • Parameters

    • event: "finish"
    • listener: () => void
        • (): void
        • Returns void

    Returns GridFSBucketWriteStream

  • Parameters

    • event: "pipe"
    • listener: (src: Readable) => void
        • (src: Readable): void
        • Parameters

          • src: Readable

          Returns void

    Returns GridFSBucketWriteStream

  • Parameters

    • event: "unpipe"
    • listener: (src: Readable) => void
        • (src: Readable): void
        • Parameters

          • src: Readable

          Returns void

    Returns GridFSBucketWriteStream

  • Parameters

    • event: string | symbol
    • listener: (...args: any[]) => void
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns GridFSBucketWriteStream

prependOnceListener

  • Parameters

    • event: "close"
    • listener: () => void
        • (): void
        • Returns void

    Returns GridFSBucketWriteStream

  • Parameters

    • event: "drain"
    • listener: () => void
        • (): void
        • Returns void

    Returns GridFSBucketWriteStream

  • Parameters

    • event: "error"
    • listener: (err: Error) => void
        • (err: Error): void
        • Parameters

          • err: Error

          Returns void

    Returns GridFSBucketWriteStream

  • Parameters

    • event: "finish"
    • listener: () => void
        • (): void
        • Returns void

    Returns GridFSBucketWriteStream

  • Parameters

    • event: "pipe"
    • listener: (src: Readable) => void
        • (src: Readable): void
        • Parameters

          • src: Readable

          Returns void

    Returns GridFSBucketWriteStream

  • Parameters

    • event: "unpipe"
    • listener: (src: Readable) => void
        • (src: Readable): void
        • Parameters

          • src: Readable

          Returns void

    Returns GridFSBucketWriteStream

  • Parameters

    • event: string | symbol
    • listener: (...args: any[]) => void
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns GridFSBucketWriteStream

rawListeners

  • rawListeners(event: string | symbol): Function[]
  • Parameters

    • event: string | symbol

    Returns Function[]

removeAllListeners

  • Parameters

    • Optional event: string | symbol

    Returns GridFSBucketWriteStream

removeListener

  • Parameters

    • event: "close"
    • listener: () => void
        • (): void
        • Returns void

    Returns GridFSBucketWriteStream

  • Parameters

    • event: "drain"
    • listener: () => void
        • (): void
        • Returns void

    Returns GridFSBucketWriteStream

  • Parameters

    • event: "error"
    • listener: (err: Error) => void
        • (err: Error): void
        • Parameters

          • err: Error

          Returns void

    Returns GridFSBucketWriteStream

  • Parameters

    • event: "finish"
    • listener: () => void
        • (): void
        • Returns void

    Returns GridFSBucketWriteStream

  • Parameters

    • event: "pipe"
    • listener: (src: Readable) => void
        • (src: Readable): void
        • Parameters

          • src: Readable

          Returns void

    Returns GridFSBucketWriteStream

  • Parameters

    • event: "unpipe"
    • listener: (src: Readable) => void
        • (src: Readable): void
        • Parameters

          • src: Readable

          Returns void

    Returns GridFSBucketWriteStream

  • Parameters

    • event: string | symbol
    • listener: (...args: any[]) => void
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns GridFSBucketWriteStream

setDefaultEncoding

  • Parameters

    • encoding: BufferEncoding

    Returns GridFSBucketWriteStream

setMaxListeners

  • Parameters

    • n: number

    Returns GridFSBucketWriteStream

uncork

  • uncork(): void
  • Returns void

write

  • write(chunk: Buffer): boolean
  • write(chunk: Buffer, callback: Callback<void>): boolean
  • write(chunk: Buffer, encoding: undefined | BufferEncoding): boolean
  • write(chunk: Buffer, encoding: undefined | BufferEncoding, callback: Callback<void>): boolean
  • Write a buffer to the stream.

    Parameters

    • chunk: Buffer

      Buffer to write

    Returns boolean

    False if this write required flushing a chunk to MongoDB. True otherwise.

  • Parameters

    • chunk: Buffer
    • callback: Callback<void>

    Returns boolean

  • Parameters

    • chunk: Buffer
    • encoding: undefined | BufferEncoding

    Returns boolean

  • Parameters

    • chunk: Buffer
    • encoding: undefined | BufferEncoding
    • callback: Callback<void>

    Returns boolean

Static getEventListener

  • getEventListener(emitter: DOMEventTarget | EventEmitter, name: string | symbol): Function[]
  • Returns a list listener for a specific emitter event name.

    Parameters

    • emitter: DOMEventTarget | EventEmitter
    • name: string | symbol

    Returns Function[]

Static listenerCount

  • listenerCount(emitter: EventEmitter, event: string | symbol): number
  • deprecated

    since v4.0.0

    Parameters

    • emitter: EventEmitter
    • event: string | symbol

    Returns number

Static on

  • on(emitter: EventEmitter, event: string, options?: StaticEventEmitterOptions): AsyncIterableIterator<any>
  • Parameters

    • emitter: EventEmitter
    • event: string
    • Optional options: StaticEventEmitterOptions

    Returns AsyncIterableIterator<any>

Static once

  • once(emitter: NodeEventTarget, event: string | symbol, options?: StaticEventEmitterOptions): Promise<any[]>
  • once(emitter: DOMEventTarget, event: string, options?: StaticEventEmitterOptions): Promise<any[]>
  • Parameters

    • emitter: NodeEventTarget
    • event: string | symbol
    • Optional options: StaticEventEmitterOptions

    Returns Promise<any[]>

  • Parameters

    • emitter: DOMEventTarget
    • event: string
    • Optional options: StaticEventEmitterOptions

    Returns Promise<any[]>

Generated using TypeDoc