本文整理汇总了PHP中OC\Files\View::getLocalFile方法的典型用法代码示例。如果您正苦于以下问题:PHP View::getLocalFile方法的具体用法?PHP View::getLocalFile怎么用?PHP View::getLocalFile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OC\Files\View
的用法示例。
在下文中一共展示了View::getLocalFile方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: create
private function create($imagePath, $square)
{
$galleryDir = \OC_User::getHome($this->user) . '/gallery/' . $this->user . '/';
$dir = dirname($imagePath);
$fileInfo = $this->view->getFileInfo($imagePath);
if (!$fileInfo) {
return false;
}
if (!is_dir($galleryDir . $dir)) {
mkdir($galleryDir . $dir, 0755, true);
}
$this->image = new \OCP\Image();
// check if file is encrypted
if ($fileInfo['encrypted'] === true) {
$fileName = $this->view->toTmpFile($imagePath);
} else {
$fileName = $this->view->getLocalFile($imagePath);
}
$this->image->loadFromFile($fileName);
if ($this->image->valid()) {
$this->image->fixOrientation();
if ($square) {
$this->image->centerCrop(200);
} else {
$this->image->fitIn($this->image->width(), 200);
if ($this->image->width() > 600) {
// max aspect ratio of 3
$this->image->crop(($this->image->width() - 600) / 2, 0, 600, 200);
}
}
$this->image->save($this->path);
}
}
示例2: isEncryptedPath
/**
* Check if a given path identifies an encrypted file
* @param string $path
* @return boolean
*/
public function isEncryptedPath($path)
{
// Disable encryption proxy so data retrieved is in its
// original form
$proxyStatus = \OC_FileProxy::$enabled;
\OC_FileProxy::$enabled = false;
$data = '';
// we only need 24 byte from the last chunk
if ($this->view->file_exists($path)) {
$handle = $this->view->fopen($path, 'r');
if (is_resource($handle)) {
// suppress fseek warining, we handle the case that fseek doesn't
// work in the else branch
if (@fseek($handle, -24, SEEK_END) === 0) {
$data = fgets($handle);
} else {
// if fseek failed on the storage we create a local copy from the file
// and read this one
fclose($handle);
$localFile = $this->view->getLocalFile($path);
$handle = fopen($localFile, 'r');
if (is_resource($handle) && fseek($handle, -24, SEEK_END) === 0) {
$data = fgets($handle);
}
}
fclose($handle);
}
}
// re-enable proxy
\OC_FileProxy::$enabled = $proxyStatus;
return Crypt::isCatfileContent($data);
}
示例3: create
public function create($imagePath, $square)
{
$galleryDir = \OC_User::getHome($this->user) . '/gallery/';
$dir = dirname($imagePath);
if (!is_dir($galleryDir . $dir)) {
mkdir($galleryDir . $dir, 0755, true);
}
if (!$this->view->file_exists($imagePath)) {
return;
}
$this->image = new \OC_Image($this->view->getLocalFile($imagePath));
if ($this->image->valid()) {
$this->image->fixOrientation();
if ($square) {
$this->image->centerCrop(200);
} else {
$this->image->fitIn(400, 200);
}
$this->image->save($this->path);
}
}
示例4: getAbsoluteBundlePath
/**
* Get the full local path to the certificate bundle for this user
*
* @param string $uid (optional) user to get the certificate bundle for, use `null` to get the system bundle
* @return string
*/
public function getAbsoluteBundlePath($uid = '')
{
if ($uid === '') {
$uid = $this->uid;
}
if ($this->needsRebundling($uid)) {
if (is_null($uid)) {
$manager = new CertificateManager(null, $this->view, $this->config);
$manager->createCertificateBundle();
} else {
$this->createCertificateBundle();
}
}
return $this->view->getLocalFile($this->getCertificateBundle($uid));
}
示例5: extractMetadata
/**
* extract the metadata from a file
*
* uses getid3 to extract metadata.
* if possible also adds content (currently only for plain text files)
* hint: use OC\Files\Filesystem::getFileInfo($path) to get metadata for the last param
*
* @author Jörn Dreyer <jfd@butonic.de>
*
* @param Zend_Search_Lucene_Document $doc to add the metadata to
* @param string $path path of the file to extract metadata from
* @param string $mimetype depending on the mimetype different extractions are performed
*
* @return void
*/
private static function extractMetadata(\Zend_Search_Lucene_Document $doc, $path, \OC\Files\View $view, $mimetype)
{
$file = $view->getLocalFile($path);
if (is_dir($file)) {
// Don't lose time analizing a directory for file-specific metadata
return;
}
$getID3 = new \getID3();
$getID3->encoding = 'UTF-8';
$data = $getID3->analyze($file);
// TODO index meta information from media files?
//show me what you got
/*foreach ($data as $key => $value) {
Util::writeLog('search_lucene',
'getid3 extracted '.$key.': '.$value,
Util::DEBUG);
if (is_array($value)) {
foreach ($value as $k => $v) {
Util::writeLog('search_lucene',
' ' . $value .'-' .$k.': '.$v,
Util::DEBUG);
}
}
}*/
if ('application/pdf' === $mimetype) {
try {
$zendpdf = \Zend_Pdf::parse($view->file_get_contents($path));
//we currently only display the filename, so we only index metadata here
if (isset($zendpdf->properties['Title'])) {
$doc->addField(\Zend_Search_Lucene_Field::UnStored('title', $zendpdf->properties['Title']));
}
if (isset($zendpdf->properties['Author'])) {
$doc->addField(\Zend_Search_Lucene_Field::UnStored('author', $zendpdf->properties['Author']));
}
if (isset($zendpdf->properties['Subject'])) {
$doc->addField(\Zend_Search_Lucene_Field::UnStored('subject', $zendpdf->properties['Subject']));
}
if (isset($zendpdf->properties['Keywords'])) {
$doc->addField(\Zend_Search_Lucene_Field::UnStored('keywords', $zendpdf->properties['Keywords']));
}
//TODO handle PDF 1.6 metadata Zend_Pdf::getMetadata()
//do the content extraction
$pdfParse = new \App_Search_Helper_PdfParser();
$body = $pdfParse->pdf2txt($zendpdf->render());
} catch (Exception $e) {
Util::writeLog('search_lucene', $e->getMessage() . ' Trace:\\n' . $e->getTraceAsString(), Util::ERROR);
}
}
if ($body != '') {
$doc->addField(\Zend_Search_Lucene_Field::UnStored('body', $body));
}
if (isset($data['error'])) {
Util::writeLog('search_lucene', 'failed to extract meta information for ' . $view->getAbsolutePath($path) . ': ' . $data['error']['0'], Util::WARN);
return;
}
}
示例6: getLocalFile
/**
* return the path to a local version of the file
* we need this because we can't know if a file is stored local or not from
* outside the filestorage and for some purposes a local file is needed
*
* @param string $path
* @return string
*/
public static function getLocalFile($path)
{
return self::$defaultInstance->getLocalFile($path);
}