PHP 클래스 yii\mongodb\file\Download

A Download object is usually created by calling [[Collection::get()]] or [[Collection::createDownload()]]. Usage example: php Yii::$app->mongodb->getFileCollection()->createDownload($document['_id'])->toFile('/path/to/file.dat'); You can use Download::substr() to read a specific part of the file: php $filePart = Yii::$app->mongodb->getFileCollection()->createDownload($document['_id'])->substr(256, 1024);
부터: 2.1
저자: Paul Klimov ([email protected])
상속: extends yii\base\Object
파일 보기 프로젝트 열기: yiisoft/yii2-mongodb 1 사용 예제들

공개 프로퍼티들

프로퍼티 타입 설명
$collection file collection to be used.

공개 메소드들

메소드 설명
getBytes ( ) : string Alias of Download::toString method.
getChunkCursor ( boolean $refresh = false ) : MongoDB\Driver\Cursor Returns file chunks read cursor.
getChunkIterator ( boolean $refresh = false ) : Iterator Returns iterator for the file chunks cursor.
getDocument ( ) : array
getFilename ( ) : string | null Returns associated file's filename.
getResource ( ) : resource Returns persistent stream resource, which can be used to read file.
getSize ( ) : integer Returns the size of the associated file.
setDocument ( array | MongoDB\BSON\ObjectID $document ) Sets data of the document to be downloaded.
substr ( integer $start, integer $length ) : string | false Return part of a file.
toFile ( string $filename ) : integer Saves download to the physical file.
toResource ( ) : resource Returns an opened stream resource, which can be used to read file.
toStream ( resource $stream ) : integer Saves file into the given stream.
toString ( ) : string Returns a string of the bytes in the associated file.
write ( string $filename ) : integer Alias of Download::toFile method.

메소드 상세

getBytes() 공개 메소드

Alias of Download::toString method.
public getBytes ( ) : string
리턴 string file content.

getChunkCursor() 공개 메소드

Returns file chunks read cursor.
public getChunkCursor ( boolean $refresh = false ) : MongoDB\Driver\Cursor
$refresh boolean whether to recreate cursor, if it is already exist.
리턴 MongoDB\Driver\Cursor chuck list cursor.

getChunkIterator() 공개 메소드

Returns iterator for the file chunks cursor.
public getChunkIterator ( boolean $refresh = false ) : Iterator
$refresh boolean whether to recreate iterator, if it is already exist.
리턴 Iterator chuck cursor iterator.

getDocument() 공개 메소드

public getDocument ( ) : array
리턴 array document to be downloaded.

getFilename() 공개 메소드

Returns associated file's filename.
public getFilename ( ) : string | null
리턴 string | null file name.

getResource() 공개 메소드

Returns persistent stream resource, which can be used to read file.
public getResource ( ) : resource
리턴 resource file stream resource.

getSize() 공개 메소드

Returns the size of the associated file.
public getSize ( ) : integer
리턴 integer file size.

setDocument() 공개 메소드

Document can be specified by its ID, in this case its data will be fetched automatically via extra query.
public setDocument ( array | MongoDB\BSON\ObjectID $document )
$document array | MongoDB\BSON\ObjectID document raw data or document ID.

substr() 공개 메소드

Return part of a file.
public substr ( integer $start, integer $length ) : string | false
$start integer reading start position. If non-negative, the returned string will start at the start'th position in file, counting from zero. If negative, the returned string will start at the start'th character from the end of file.
$length integer number of bytes to read. If given and is positive, the string returned will contain at most length characters beginning from start (depending on the length of file). If given and is negative, then that many characters will be omitted from the end of file (after the start position has been calculated when a start is negative).
리턴 string | false the extracted part of file or `false` on failure

toFile() 공개 메소드

Saves download to the physical file.
public toFile ( string $filename ) : integer
$filename string name of the physical file.
리턴 integer number of written bytes.

toResource() 공개 메소드

Note: each invocation of this method will create new file resource.
public toResource ( ) : resource
리턴 resource stream resource.

toStream() 공개 메소드

Saves file into the given stream.
public toStream ( resource $stream ) : integer
$stream resource stream, which file should be saved to.
리턴 integer number of written bytes.

toString() 공개 메소드

Returns a string of the bytes in the associated file.
public toString ( ) : string
리턴 string file content.

write() 공개 메소드

Alias of Download::toFile method.
public write ( string $filename ) : integer
$filename string name of the physical file.
리턴 integer number of written bytes.

프로퍼티 상세

$collection 공개적으로 프로퍼티

file collection to be used.
public $collection