PHP Class Phalcon\Db\Adapter\MongoDB\GridFS\WritableStream

Datei anzeigen Open project: phalcon/incubator Class Usage Examples

Public Methods

Method Description
__construct ( CollectionWrapper $collectionWrapper, string $filename, array $options = [] ) Constructs a writable GridFS stream.
close ( ) Closes an active stream and flushes all buffered data to GridFS.
getChunkSize ( )
getFile ( )
getId ( )
getLength ( )
getSize ( )
insertChunks ( string $toWrite ) : integer Inserts binary data into GridFS via chunks.
isEOF ( )
uploadFromStream ( resource $source ) : MongoDB\BSON\ObjectId Writes the contents of a readable stream to a GridFS file.

Private Methods

Method Description
abort ( )
fileCollectionInsert ( )
insertChunk ( $data )
readChunk ( $source )

Method Details

__construct() public method

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). * 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.
public __construct ( CollectionWrapper $collectionWrapper, string $filename, array $options = [] )
$collectionWrapper CollectionWrapper GridFS collection wrapper
$filename string Filename
$options array Upload options

close() public method

Closes an active stream and flushes all buffered data to GridFS.
public close ( )

getChunkSize() public method

public getChunkSize ( )

getFile() public method

public getFile ( )

getId() public method

public getId ( )

getLength() public method

public getLength ( )

getSize() public method

public getSize ( )

insertChunks() public method

Data will be buffered internally until chunkSizeBytes are accumulated, at which point a chunk's worth of data will be inserted and the buffer reset.
public insertChunks ( string $toWrite ) : integer
$toWrite string Binary data to write
return integer

isEOF() public method

public isEOF ( )

uploadFromStream() public method

Writes the contents of a readable stream to a GridFS file.
public uploadFromStream ( resource $source ) : MongoDB\BSON\ObjectId
$source resource Readable stream
return MongoDB\BSON\ObjectId