本文整理汇总了PHP中PhabricatorFile::getStorageHandle方法的典型用法代码示例。如果您正苦于以下问题:PHP PhabricatorFile::getStorageHandle方法的具体用法?PHP PhabricatorFile::getStorageHandle怎么用?PHP PhabricatorFile::getStorageHandle使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PhabricatorFile
的用法示例。
在下文中一共展示了PhabricatorFile::getStorageHandle方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: newChunkQuery
private function newChunkQuery(PhabricatorUser $viewer, PhabricatorFile $file)
{
$engine = $file->instantiateStorageEngine();
if (!$engine->isChunkEngine()) {
throw new Exception(pht('File "%s" does not have chunks!', $file->getPHID()));
}
return id(new PhabricatorFileChunkQuery())->setViewer($viewer)->withChunkHandles(array($file->getStorageHandle()));
}
示例2: writeChunk
private function writeChunk(PhabricatorFile $file, PhabricatorFileStorageEngine $engine)
{
$offset = $this->getTotalBytesWritten();
$max_length = $engine->getChunkSize();
$rope = $this->getRope();
$data = $rope->getPrefixBytes($max_length);
$actual_length = strlen($data);
$rope->removeBytesFromHead($actual_length);
$chunk_data = PhabricatorFile::newFromFileData($data, array('name' => $file->getMonogram() . '.chunk-' . $offset, 'viewPolicy' => PhabricatorPolicies::POLICY_NOONE));
$chunk = PhabricatorFileChunk::initializeNewChunk($file->getStorageHandle(), $offset, $offset + $actual_length);
$chunk->setDataFilePHID($chunk_data->getPHID())->save();
$this->setTotalBytesWritten($offset + $actual_length);
return $chunk;
}
示例3: getRawFileDataIterator
public function getRawFileDataIterator(PhabricatorFile $file, $begin, $end)
{
// The default implementation is trivial and just loads the entire file
// upfront.
$data = $this->readFile($file->getStorageHandle());
if ($begin !== null && $end !== null) {
$data = substr($data, $begin, $end - $begin);
} else {
if ($begin !== null) {
$data = substr($data, $begin);
} else {
if ($end !== null) {
$data = substr($data, 0, $end);
}
}
}
return array($data);
}
示例4: getRawFileDataIterator
public function getRawFileDataIterator(PhabricatorFile $file, $begin, $end)
{
$chunks = id(new PhabricatorFileChunkQuery())->setViewer(PhabricatorUser::getOmnipotentUser())->withChunkHandles(array($file->getStorageHandle()))->withByteRange($begin, $end)->needDataFiles(true)->execute();
return new PhabricatorFileChunkIterator($chunks, $begin, $end);
}
示例5: buildPropertyViews
private function buildPropertyViews(PHUIObjectBoxView $box, PhabricatorFile $file)
{
$request = $this->getRequest();
$viewer = $request->getUser();
$tab_group = id(new PHUITabGroupView());
$box->addTabGroup($tab_group);
$properties = id(new PHUIPropertyListView());
$tab_group->addTab(id(new PHUITabView())->setName(pht('Details'))->setKey('details')->appendChild($properties));
if ($file->getAuthorPHID()) {
$properties->addProperty(pht('Author'), $viewer->renderHandle($file->getAuthorPHID()));
}
$properties->addProperty(pht('Created'), phabricator_datetime($file->getDateCreated(), $viewer));
$finfo = id(new PHUIPropertyListView());
$tab_group->addTab(id(new PHUITabView())->setName(pht('File Info'))->setKey('info')->appendChild($finfo));
$finfo->addProperty(pht('Size'), phutil_format_bytes($file->getByteSize()));
$finfo->addProperty(pht('Mime Type'), $file->getMimeType());
$width = $file->getImageWidth();
if ($width) {
$finfo->addProperty(pht('Width'), pht('%s px', new PhutilNumber($width)));
}
$height = $file->getImageHeight();
if ($height) {
$finfo->addProperty(pht('Height'), pht('%s px', new PhutilNumber($height)));
}
$is_image = $file->isViewableImage();
if ($is_image) {
$image_string = pht('Yes');
$cache_string = $file->getCanCDN() ? pht('Yes') : pht('No');
} else {
$image_string = pht('No');
$cache_string = pht('Not Applicable');
}
$types = array();
if ($file->isViewableImage()) {
$types[] = pht('Image');
}
if ($file->isVideo()) {
$types[] = pht('Video');
}
if ($file->isAudio()) {
$types[] = pht('Audio');
}
if ($file->getCanCDN()) {
$types[] = pht('Can CDN');
}
$builtin = $file->getBuiltinName();
if ($builtin !== null) {
$types[] = pht('Builtin ("%s")', $builtin);
}
if ($file->getIsProfileImage()) {
$types[] = pht('Profile');
}
if ($types) {
$types = implode(', ', $types);
$finfo->addProperty(pht('Attributes'), $types);
}
$storage_properties = new PHUIPropertyListView();
$tab_group->addTab(id(new PHUITabView())->setName(pht('Storage'))->setKey('storage')->appendChild($storage_properties));
$storage_properties->addProperty(pht('Engine'), $file->getStorageEngine());
$format_key = $file->getStorageFormat();
$format = PhabricatorFileStorageFormat::getFormat($format_key);
if ($format) {
$format_name = $format->getStorageFormatName();
} else {
$format_name = pht('Unknown ("%s")', $format_key);
}
$storage_properties->addProperty(pht('Format'), $format_name);
$storage_properties->addProperty(pht('Handle'), $file->getStorageHandle());
$phids = $file->getObjectPHIDs();
if ($phids) {
$attached = new PHUIPropertyListView();
$tab_group->addTab(id(new PHUITabView())->setName(pht('Attached'))->setKey('attached')->appendChild($attached));
$attached->addProperty(pht('Attached To'), $viewer->renderHandleList($phids));
}
if ($file->isViewableImage()) {
$image = phutil_tag('img', array('src' => $file->getViewURI(), 'class' => 'phui-property-list-image'));
$linked_image = phutil_tag('a', array('href' => $file->getViewURI()), $image);
$media = id(new PHUIPropertyListView())->addImageContent($linked_image);
$box->addPropertyList($media);
} else {
if ($file->isVideo()) {
$video = phutil_tag('video', array('controls' => 'controls', 'class' => 'phui-property-list-video'), phutil_tag('source', array('src' => $file->getViewURI(), 'type' => $file->getMimeType())));
$media = id(new PHUIPropertyListView())->addImageContent($video);
$box->addPropertyList($media);
} else {
if ($file->isAudio()) {
$audio = phutil_tag('audio', array('controls' => 'controls', 'class' => 'phui-property-list-audio'), phutil_tag('source', array('src' => $file->getViewURI(), 'type' => $file->getMimeType())));
$media = id(new PHUIPropertyListView())->addImageContent($audio);
$box->addPropertyList($media);
}
}
}
$engine = null;
try {
$engine = $file->instantiateStorageEngine();
} catch (Exception $ex) {
// Don't bother raising this anywhere for now.
}
if ($engine) {
if ($engine->isChunkEngine()) {
//.........这里部分代码省略.........
示例6: buildPropertyViews
private function buildPropertyViews(PHUIObjectBoxView $box, PhabricatorFile $file, PhabricatorActionListView $actions)
{
$request = $this->getRequest();
$user = $request->getUser();
$properties = id(new PHUIPropertyListView());
$properties->setActionList($actions);
$box->addPropertyList($properties, pht('Details'));
if ($file->getAuthorPHID()) {
$properties->addProperty(pht('Author'), $this->getHandle($file->getAuthorPHID())->renderLink());
}
$properties->addProperty(pht('Created'), phabricator_datetime($file->getDateCreated(), $user));
$finfo = id(new PHUIPropertyListView());
$box->addPropertyList($finfo, pht('File Info'));
$finfo->addProperty(pht('Size'), phutil_format_bytes($file->getByteSize()));
$finfo->addProperty(pht('Mime Type'), $file->getMimeType());
$width = $file->getImageWidth();
if ($width) {
$finfo->addProperty(pht('Width'), pht('%s px', new PhutilNumber($width)));
}
$height = $file->getImageHeight();
if ($height) {
$finfo->addProperty(pht('Height'), pht('%s px', new PhutilNumber($height)));
}
$is_image = $file->isViewableImage();
if ($is_image) {
$image_string = pht('Yes');
$cache_string = $file->getCanCDN() ? pht('Yes') : pht('No');
} else {
$image_string = pht('No');
$cache_string = pht('Not Applicable');
}
$finfo->addProperty(pht('Viewable Image'), $image_string);
$finfo->addProperty(pht('Cacheable'), $cache_string);
$storage_properties = new PHUIPropertyListView();
$box->addPropertyList($storage_properties, pht('Storage'));
$storage_properties->addProperty(pht('Engine'), $file->getStorageEngine());
$storage_properties->addProperty(pht('Format'), $file->getStorageFormat());
$storage_properties->addProperty(pht('Handle'), $file->getStorageHandle());
$phids = $file->getObjectPHIDs();
if ($phids) {
$attached = new PHUIPropertyListView();
$box->addPropertyList($attached, pht('Attached'));
$attached->addProperty(pht('Attached To'), $this->renderHandlesForPHIDs($phids));
}
if ($file->isViewableImage()) {
$image = phutil_tag('img', array('src' => $file->getViewURI(), 'class' => 'phui-property-list-image'));
$linked_image = phutil_tag('a', array('href' => $file->getViewURI()), $image);
$media = id(new PHUIPropertyListView())->addImageContent($linked_image);
$box->addPropertyList($media);
} else {
if ($file->isAudio()) {
$audio = phutil_tag('audio', array('controls' => 'controls', 'class' => 'phui-property-list-audio'), phutil_tag('source', array('src' => $file->getViewURI(), 'type' => $file->getMimeType())));
$media = id(new PHUIPropertyListView())->addImageContent($audio);
$box->addPropertyList($media);
}
}
}