Example #1
0
 /**
  * Normalize a DataObject
  *
  * @param   DataObject  $object
  * @return  array       file metadata
  */
 protected function normalizeObject(DataObject $object)
 {
     $name = $object->getName();
     if ($this->prefix) {
         $name = substr($name, strlen($this->prefix));
     }
     $mimetype = explode('; ', $object->getContentType());
     return array('type' => 'file', 'dirname' => Util::dirname($name), 'path' => $name, 'timestamp' => strtotime($object->getLastModified()), 'mimetype' => reset($mimetype), 'size' => $object->getContentLength());
 }
Example #2
0
 /**
  * {@inheritdoc}
  */
 protected function normalizeObject(DataObject $object)
 {
     $name = $object->getName();
     $name = $this->removePathPrefix($name);
     $mimetype = explode('; ', $object->getContentType());
     return ['type' => in_array('application/directory', $mimetype) ? 'dir' : 'file', 'dirname' => Util::dirname($name), 'path' => $name, 'timestamp' => strtotime($object->getLastModified()), 'mimetype' => reset($mimetype), 'size' => $object->getContentLength()];
 }
Example #3
0
 /**
  * @param DataObject $object
  * @param bool $includeContent
  *
  * @return File
  */
 private function generateFileFromDataObject(DataObject $object, $includeContent = true)
 {
     $file = new File();
     if ($includeContent) {
         $file->content = $object->getContent();
     }
     $file->mime = $object->getContentType();
     $chunks = explode('/', $object->getName());
     $file->name = array_pop($chunks);
     $file->size = $object->getContentLength();
     return $file;
 }