Search moodle.org's
Developer Documentation

See Release Notes
Long Term Support Release

  • Bug fixes for general core bugs in 3.9.x will end* 10 May 2021 (12 months).
  • Bug fixes for security issues in 3.9.x will end* 8 May 2023 (36 months).
  • PHP version: minimum PHP 7.2.0 Note: minimum PHP version has increased since Moodle 3.8. PHP 7.3.x and 7.4.x are supported too.

Differences Between: [Versions 39 and 311] [Versions 39 and 400] [Versions 39 and 401]

(no description)

File Size: 314 lines (9 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class

WritableStream:: (10 methods):
  __construct()
  __debugInfo()
  close()
  getFile()
  getSize()
  tell()
  writeBytes()
  abort()
  fileCollectionInsert()
  insertChunkFromBuffer()


Class: WritableStream  - X-Ref

WritableStream abstracts the process of writing a GridFS file.

__construct(CollectionWrapper $collectionWrapper, $filename, array $options = [])   X-Ref
Constructs a writable GridFS stream.

Supported options:

* _id (mixed): File document identifier. Defaults to a new ObjectId.

* aliases (array of strings): DEPRECATED An array of aliases.
Applications wishing to store aliases should add an aliases field to
the metadata document instead.

* chunkSizeBytes (integer): The chunk size in bytes. Defaults to
261120 (i.e. 255 KiB).

* disableMD5 (boolean): When true, no MD5 sum will be generated.
Defaults to "false".

* contentType (string): DEPRECATED content type to be stored with the
file. This information should now be added to the metadata.

* metadata (document): User data for the "metadata" field of the files
collection document.

param: CollectionWrapper $collectionWrapper GridFS collection wrapper
param: string            $filename          Filename
param: array             $options           Upload options

__debugInfo()   X-Ref
Return internal properties for debugging purposes.

return: array

close()   X-Ref
Closes an active stream and flushes all buffered data to GridFS.


getFile()   X-Ref
Return the stream's file document.

return: stdClass

getSize()   X-Ref
Return the stream's size in bytes.

Note: this value will increase as more data is written to the stream.

return: integer

tell()   X-Ref
Return the current position of the stream.

This is the offset within the stream where the next byte would be
written. Since seeking is not supported and writes are appended, this is
always the end of the stream.

return: integer

writeBytes($data)   X-Ref
Inserts binary data into GridFS via chunks.

Data will be buffered internally until chunkSizeBytes are accumulated, at
which point a chunk document will be inserted and the buffer reset.

param: string $data Binary data to write
return: integer

abort()   X-Ref
No description

fileCollectionInsert()   X-Ref
No description

insertChunkFromBuffer()   X-Ref
No description