Exemple #1
0
 public function inspect(Version $fv)
 {
     $at1 = FileAttributeKey::getByHandle('duration');
     $at2 = FileAttributeKey::getByHandle('width');
     $at3 = FileAttributeKey::getByHandle('height');
     // we killed $path here because the file might be hosted remotely.
     // @TODO add in support for streams through the $filesystem object.
     $cf = Core::make('helper/concrete/file');
     $fs = $fv->getFile()->getFileStorageLocationObject()->getFileSystemObject();
     $fp = $fs->readStream($cf->prefix($fv->getPrefix(), $fv->getFileName()));
     @fseek($fp, 27);
     $onMetaData = fread($fp, 10);
     //if ($onMetaData != 'onMetaData') exit('No meta data available in this file! Fix it using this tool: http://www.buraks.com/flvmdi/');
     @fseek($fp, 16, SEEK_CUR);
     $duration = array_shift(unpack('d', strrev(fread($fp, 8))));
     @fseek($fp, 8, SEEK_CUR);
     $width = array_shift(unpack('d', strrev(fread($fp, 8))));
     @fseek($fp, 9, SEEK_CUR);
     $height = array_shift(unpack('d', strrev(fread($fp, 8))));
     $fv->setAttribute($at1, $duration);
     $fv->setAttribute($at2, $width);
     $fv->setAttribute($at3, $height);
 }
 /**
  * Get the path for a file version
  *
  * @param Version $file_version
  * @param ThumbnailVersion $thumbnail
  * @return null|string
  */
 public function getPath(Version $file_version, ThumbnailVersion $thumbnail)
 {
     /** @var File $file */
     $file = $file_version->getFile();
     $file_id = $file->getFileID();
     $storage_location = $file->getFileStorageLocationObject();
     $configuration = $storage_location->getConfigurationObject();
     $version_id = $file_version->getFileVersionID();
     $storage_location_id = $storage_location->getID();
     $thumbnail_handle = $thumbnail->getHandle();
     $path = $this->getStoredPath($file_id, $version_id, $storage_location_id, $thumbnail_handle);
     if ($path) {
         if ($configuration instanceof DeferredConfigurationInterface) {
             return $configuration->getPublicURLToFile($path);
         }
         return $path;
     } elseif ($path = $this->determinePath($file_version, $thumbnail, $storage_location, $configuration)) {
         $this->storePath($path, $file_id, $version_id, $storage_location_id, $thumbnail_handle);
         if ($configuration instanceof DeferredConfigurationInterface) {
             return $configuration->getPublicURLToFile($path);
         }
         return $path;
     }
 }
Exemple #3
0
 public function getFilePath(FileVersion $fv)
 {
     $prefix = $fv->getPrefix();
     $filename = $fv->getFileName();
     $hi = Core::make('helper/file');
     $ii = Core::make('helper/concrete/file');
     $f1 = REL_DIR_FILES_THUMBNAILS . '/' . $this->getDirectoryName() . $ii->prefix($prefix, $filename);
     $f2 = REL_DIR_FILES_THUMBNAILS . '/' . $this->getDirectoryName() . $ii->prefix($prefix, $hi->replaceExtension($filename, 'jpg'));
     // 5.7.4 keeps extension; older sets it to .jpg
     $filesystem = $fv->getFile()->getFileStorageLocationObject()->getFileSystemObject();
     if ($filesystem->has($f1)) {
         return $f1;
     }
     //fallback
     return $f2;
 }
 /**
  * {@inheritDoc}
  */
 public function getFile()
 {
     $this->__initializer__ && $this->__initializer__->__invoke($this, 'getFile', array());
     return parent::getFile();
 }
 /**
  * returns the File object associated with this FileVersion object
  *
  * @return \File
  */
 public function getFile()
 {
     return parent::getFile();
 }