Ejemplo n.º 1
0
 /**
  * Get Object related information
  * 
  * @param string $path The object path
  * 
  * @return array The object info
  */
 public function getObjectInfo($path)
 {
     $result = false;
     $obj = null;
     // check if path is set
     if (!$path) {
         return false;
     }
     // get info from s3
     $result = $this->s3->getObjectInfo($this->bucket, $path);
     // propagate S3 object errors to storage object
     $this->s3->propagateToObject($this);
     // if something went wrong, report
     if ($result == FALSE) {
         $this->setError(JText::_('PLG_ZLFRAMEWORK_STRG_ERR_SOMETHING_WENT_WRONG'));
         return false;
     }
     // prepare object
     $obj = array();
     $obj['name'] = basename($path);
     $obj['path'] = $path;
     $obj['ext'] = JFile::getExt($obj['name']);
     $obj['basename'] = basename($obj['name'], '.' . $obj['ext']);
     $obj['content_type'] = $this->app->zlfw->filesystem->getContentType($obj['name']);
     $obj['size']['value'] = $this->app->zlfw->filesystem->returnBytes($result['size']);
     $obj['size']['display'] = $this->app->zlfw->filesystem->formatFilesize($obj['size']['value'], 'KB');
     // 'preview'	=> $this->s3->getAuthenticatedURL($this->bucket, $path, 900);
     // set the object type
     if (preg_match('/\\/$/', $path)) {
         // is folder, they have a slash at the end
         $obj['type'] = 'folder';
     } else {
         $obj['type'] = 'file';
     }
     return $obj;
 }