/**
  * Normalize the object result array.
  *
  * @param array  $response
  * @param string $path
  *
  * @return array
  */
 protected function normalizeResponse(array $response, $path = null)
 {
     $result = ['path' => $path ?: $this->removePathPrefix($response['Key'])];
     $result = array_merge($result, Util::pathinfo($result['path']));
     if (isset($response['LastModified'])) {
         $result['timestamp'] = strtotime($response['LastModified']);
     }
     if (substr($result['path'], -1) === '/') {
         $result['type'] = 'dir';
         $result['path'] = rtrim($result['path'], '/');
         return $result;
     }
     return array_merge($result, Util::map($response, static::$resultMap), ['type' => 'file']);
 }
Пример #2
0
 /**
  * Normalize a result from AWS
  *
  * @param   string  $object
  * @param   string  $path
  * @return  array   file metadata
  */
 protected function normalizeObject($object, $path = null)
 {
     $result = array('path' => $path ?: $object['Key']);
     if (isset($object['LastModified'])) {
         $result['timestamp'] = strtotime($object['LastModified']);
     }
     $result = array_merge($result, Util::map($object, static::$resultMap), array('type' => 'file'));
     $result['dirname'] = Util::dirname($result['path']);
     if (isset($result['contents'])) {
         $result['contents'] = (string) $result['contents'];
     }
     return $result;
 }
 /**
  * Normalize a zip response array.
  *
  * @param array $object
  *
  * @return array
  */
 protected function normalizeObject(array $object)
 {
     if (substr($object['name'], -1) === '/') {
         return ['path' => $this->removePathPrefix(trim($object['name'], '/')), 'type' => 'dir'];
     }
     $result = ['type' => 'file'];
     $normalised = Util::map($object, static::$resultMap);
     $normalised['path'] = $this->removePathPrefix($normalised['path']);
     return array_merge($result, $normalised);
 }
Пример #4
0
 protected function normalizeObject($object, $path = null)
 {
     $result = array('path' => $path ?: ltrim($object['path'], '/'));
     if (isset($object['modified'])) {
         $result['timestamp'] = strtotime($object['modified']);
     }
     $result = array_merge($result, Util::map($object, static::$resultMap));
     $result['type'] = $object['is_dir'] ? 'dir' : 'file';
     return $result;
 }
Пример #5
0
 /**
  * Normalize a result from Copy.
  *
  * @param stdClass $object
  * @param string   $path
  *
  * @return array|false file metadata
  */
 protected function normalizeObject($object, $path)
 {
     if (!$object instanceof stdClass) {
         return false;
     }
     if (isset($object->modified_time)) {
         $timestamp = $object->modified_time;
     }
     $path = trim($this->removePathPrefix($path), '/');
     $result = Util::map((array) $object, static::$resultMap);
     return compact('timestamp', 'path') + $result;
 }
Пример #6
0
 /**
  * @inheritdoc
  */
 public function getMetadata($path)
 {
     $connection = $this->getConnection();
     $info = $connection->stat($path);
     if ($info === false) {
         return false;
     }
     $result = Util::map($info, $this->statMap);
     $result['type'] = $info['type'] === NET_SFTP_TYPE_DIRECTORY ? 'dir' : 'file';
     $result['visibility'] = $info['permissions'] & $this->permPublic ? 'public' : 'private';
     return $result;
 }
Пример #7
0
 protected function normalizeObject($object, $path)
 {
     if (!isset($object['{DAV:}getcontentlength'])) {
         return array('type' => 'dir', 'path' => trim($path, '/'));
     }
     $result = Util::map($object, static::$resultMap);
     if (isset($object['{DAV:}getlastmodified'])) {
         $result['timestamp'] = strtotime($object['{DAV:}getlastmodified']);
     }
     $result['type'] = 'file';
     $result['path'] = trim($path, '/');
     return $result;
 }
Пример #8
0
 /**
  * Normalize a result from Copy.
  *
  * @param stdClass $object
  * @param string   $path
  *
  * @return array|false file metadata
  */
 protected function normalizeObject($object, $path)
 {
     if (is_a($object, 'stdClass') === false) {
         return false;
     }
     if (isset($object->modified_time)) {
         $timestamp = strtotime($object->modified_time);
     }
     $result = Util::map((array) $object, static::$resultMap);
     return compact('timestamp', 'path') + $result;
 }
Пример #9
0
 protected function normalizeObject(array $object)
 {
     if (substr($object['name'], -1) === '/') {
         return array('path' => trim($object['name'], '/'), 'type' => 'dir');
     }
     $result = array('type' => 'file');
     return array_merge($result, Util::map($object, static::$resultMap));
 }
Пример #10
0
 /**
  * {@inheritdoc}
  */
 public function getVisibility($path)
 {
     $metadata = $this->getMetadata($path);
     return isset($metadata['visibility']) ? Util::map($metadata, ['visibility' => 'visibility']) : ['visibility' => 'public'];
 }
Пример #11
0
 /**
  * Normalize a Dropbox response.
  *
  * @param        $response
  * @param string $path
  *
  * @return array
  */
 protected function normalizeResponse(array $response, $path = null)
 {
     $result = ['path' => trim($path ?: $response['path'], '/')];
     if (isset($response['modified'])) {
         $result['timestamp'] = strtotime($response['modified']);
     }
     $result = array_merge($result, Util::map($response, static::$resultMap));
     $result['type'] = $response['is_dir'] ? 'dir' : 'file';
     return $result;
 }
Пример #12
0
 /**
  * Normalize a result from Google
  *
  * @param   string  $object
  * @param   string  $path
  * @return  array   file metadata
  */
 protected function normalizeObject($object, $path = null)
 {
     $newObject = array();
     foreach ((array) $object as $key => $value) {
         if (substr($key, 0, 3) == "*") {
             $key = substr($key, 3);
         }
         $newObject[$key] = $value;
     }
     $object = $newObject;
     if (isset($object["dirname"])) {
         $result = array('path' => $object['dirname'] . "/" . $object['id']);
     } else {
         $result = array('path' => $object['id']);
     }
     if (isset($object['modifiedDate'])) {
         $result['timestamp'] = strtotime($object['modifiedDate']);
     }
     $result["basename"] = $object["title"];
     if ($object['mimeType'] == 'application/vnd.google-apps.folder') {
         $result['type'] = 'dir';
         $result['path'] = rtrim($result['path'], '/');
         $result['dirname'] = Util::dirname($result['path']);
         return $result;
     }
     $result = array_merge($result, Util::map($object, static::$resultMap), array('type' => 'file'));
     $result['dirname'] = Util::dirname($result['path']);
     if (isset($result['contents'])) {
         $result['contents'] = (string) $result['contents'];
     }
     return $result;
 }
Пример #13
0
 /**
  * List contents of a directory.
  *
  * @param string $directory
  * @param bool   $recursive
  *
  * @return array
  */
 public function listContents($directory = '', $recursive = false)
 {
     $results = [];
     if ($directory != '') {
         if (substr($directory, -1) != '/') {
             $directory = $directory . '/';
         }
     }
     if ($recursive == false) {
         $dirs = $this->storage->getBucket($this->bucket, $directory, null, 10000, '/');
         foreach ($dirs as $dir) {
             if (!array_key_exists('subdir', $dir)) {
                 array_push($results, Util::map($dir, ['content_type' => 'type', 'name' => 'path', 'last_modified' => 'timestamp', 'bytes' => 'size']));
             }
         }
         return $results;
     } else {
         $dirs = $this->storage->getBucket($this->bucket, $directory, null, 10000, '/');
         foreach ($dirs as $dir) {
             if (!array_key_exists('subdir', $dir)) {
                 array_push($results, Util::map($dir, ['content_type' => 'type', 'name' => 'path', 'last_modified' => 'timestamp', 'bytes' => 'size']));
             } else {
                 $results = array_merge($results, $this->listContents($dir['subdir'], true));
             }
         }
         return $results;
     }
 }
Пример #14
0
 /**
  * Normalize a result from AWS
  *
  * @param   array  $object
  * @param   string  $path
  * @return  array   file metadata
  */
 protected function normalizeObject(array $object, $path = null)
 {
     $result = array('path' => $path ?: $this->removePathPrefix($object['Key']));
     $result['dirname'] = Util::dirname($result['path']);
     if (isset($object['LastModified'])) {
         $result['timestamp'] = strtotime($object['LastModified']);
     }
     if (substr($result['path'], -1) === '/') {
         $result['type'] = 'dir';
         $result['path'] = rtrim($result['path'], '/');
         return $result;
     }
     $result = array_merge($result, Util::map($object, static::$resultMap), array('type' => 'file'));
     return $result;
 }