public function write($path, $contents, $config = null) { $dirname = Util::dirname($path); $config = Util::ensureConfig($config); if (!empty($dirname) && !$this->has($dirname)) { $this->createDir($dirname); } if (!$this->archive->addFromString($path, $contents)) { return false; } $result = compact('path', 'contents'); if ($config && $config->get('visibility')) { throw new LogicException(get_class($this) . ' does not support visibility settings.'); } return $result; }
/** * Check whether an object has been cached * * @param string $path * @return boolean cached boolean */ public function has($path) { if (!isset($this->cache[$path])) { return $this->isComplete(Util::dirname($path), false) ? false : null; } return $this->cache[$path] !== false; }
/** * 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()); }
public function write($path, $contents, $config = null) { $connection = $this->getConnection(); $this->ensureDirectory(Util::dirname($path)); $config = Util::ensureConfig($config); if (!$connection->put($path, $contents, NET_SFTP_STRING)) { return false; } if ($config && ($visibility = $config->get('visibility'))) { $this->setVisibility($path, $visibility); } return compact('contents', 'visibility', 'path'); }
/** * 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']); } if (substr($result['path'], -1) === '/') { $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; }
public function writeStream($path, $resource, $config = null) { $this->ensureDirectory(Util::dirname($path)); $config = Util::ensureConfig($config); if (!ftp_fput($this->getConnection(), $path, $resource, FTP_BINARY)) { return false; } if ($visibility = $config->get('visibility')) { $this->setVisibility($path, $visibility); } return compact('path', 'visibility'); }