API 参考
    正在准备搜索索引...

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

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

    索引

    构造函数

    属性

    bucket: GridFSBucket
    bufToStore: Buffer
    chunkSizeBytes: number
    done: boolean
    filename: string
    length: number
    n: number
    pos: number
    state: {
        aborted: boolean;
        errored: boolean;
        outstandingRequests: number;
        streamEnd: boolean;
    }
    writeConcern?: WriteConcern

    方法

    • Places this write stream into an aborted state (all future writes fail) and deletes all chunks that have already been written.

      返回 Promise<void>

    • Tells the stream that no more data will be coming in. The stream will persist the remaining data to MongoDB, write the files document, and then emit a 'finish' event.

      返回 this

    • Tells the stream that no more data will be coming in. The stream will persist the remaining data to MongoDB, write the files document, and then emit a 'finish' event.

      参数

      • chunk: Buffer

        Buffer to write

      返回 this

    • Tells the stream that no more data will be coming in. The stream will persist the remaining data to MongoDB, write the files document, and then emit a 'finish' event.

      参数

      • callback: Callback<void | GridFSFile>

        Function to call when all files and chunks have been persisted to MongoDB

      返回 this

    • Tells the stream that no more data will be coming in. The stream will persist the remaining data to MongoDB, write the files document, and then emit a 'finish' event.

      参数

      • chunk: Buffer

        Buffer to write

      • callback: Callback<void | GridFSFile>

        Function to call when all files and chunks have been persisted to MongoDB

      返回 this

    • Tells the stream that no more data will be coming in. The stream will persist the remaining data to MongoDB, write the files document, and then emit a 'finish' event.

      参数

      • chunk: Buffer

        Buffer to write

      • encoding: BufferEncoding

        Optional encoding for the buffer

      返回 this

    • Tells the stream that no more data will be coming in. The stream will persist the remaining data to MongoDB, write the files document, and then emit a 'finish' event.

      参数

      • chunk: Buffer

        Buffer to write

      • encoding: undefined | BufferEncoding

        Optional encoding for the buffer

      • callback: Callback<void | GridFSFile>

        Function to call when all files and chunks have been persisted to MongoDB

      返回 this

    • Write a buffer to the stream.

      参数

      • chunk: string | Buffer<ArrayBufferLike>

        Buffer to write

      返回 boolean

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

    • Write a buffer to the stream.

      参数

      • chunk: string | Buffer<ArrayBufferLike>

        Buffer to write

      • callback: Callback<void>

        Function to call when the chunk was added to the buffer, or if the entire chunk was persisted to MongoDB if this chunk caused a flush.

      返回 boolean

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

    • Write a buffer to the stream.

      参数

      • chunk: string | Buffer<ArrayBufferLike>

        Buffer to write

      • encoding: undefined | BufferEncoding

      返回 boolean

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

    • Write a buffer to the stream.

      参数

      • chunk: string | Buffer<ArrayBufferLike>

        Buffer to write

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

        Function to call when the chunk was added to the buffer, or if the entire chunk was persisted to MongoDB if this chunk caused a flush.

      返回 boolean

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

    Events

    CLOSE: "close"
    ERROR: "error"
    FINISH: "finish"

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