本文整理匯總了PHP中PhabricatorFile::newChunkedFile方法的典型用法代碼示例。如果您正苦於以下問題:PHP PhabricatorFile::newChunkedFile方法的具體用法?PHP PhabricatorFile::newChunkedFile怎麽用?PHP PhabricatorFile::newChunkedFile使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類PhabricatorFile
的用法示例。
在下文中一共展示了PhabricatorFile::newChunkedFile方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: writeChunkedFile
private function writeChunkedFile()
{
$engine = $this->getChunkEngine();
$parameters = $this->getNewFileParameters();
$parameters = array('isPartial' => true) + $parameters;
$data_length = $this->getDataLength();
if ($data_length !== null) {
$length = $data_length;
} else {
$length = 0;
}
$file = PhabricatorFile::newChunkedFile($engine, $length, $parameters);
$file->save();
$rope = $this->getRope();
// Read the source, writing chunks as we get enough data.
while ($this->readFileData()) {
while (true) {
$rope_length = $rope->getByteLength();
if ($rope_length < $engine->getChunkSize()) {
break;
}
$this->writeChunk($file, $engine);
}
}
// If we have extra bytes at the end, write them.
if ($rope->getByteLength()) {
$this->writeChunk($file, $engine);
}
$file->setIsPartial(0);
if ($data_length === null) {
$file->setByteSize($this->getTotalBytesWritten());
}
$file->save();
return $file;
}
示例2: allocateChunks
public function allocateChunks($length, array $properties)
{
$file = PhabricatorFile::newChunkedFile($this, $length, $properties);
$chunk_size = $this->getChunkSize();
$handle = $file->getStorageHandle();
$chunks = array();
for ($ii = 0; $ii < $length; $ii += $chunk_size) {
$chunks[] = PhabricatorFileChunk::initializeNewChunk($handle, $ii, min($ii + $chunk_size, $length));
}
$file->openTransaction();
foreach ($chunks as $chunk) {
$chunk->save();
}
$file->save();
$file->saveTransaction();
return $file;
}