/** * Write a file * * @param $path * @param $contents * @param null $config * @return array|bool */ public function write($path, $contents, $config = null) { $type = 'file'; $config = Util::ensureConfig($config); $result = compact('contents', 'type', 'size', 'path'); if ($visibility = $config->get('visibility')) { $result['visibility'] = $visibility; } return $result; }
public function write($path, $contents, $config = null) { $config = Util::ensureConfig($config); $this->client->request('PUT', $path, $contents); $result = compact('path', 'contents'); if ($config && ($visibility = $config->get('visibility'))) { $this->setVisibility($path, $visibility); } return $result; }
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; }
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'); }
/** * Write using a stream * * @param $path * @param $resource * @param null $config * @return array|bool */ public function writeStream($path, $resource, $config = null) { rewind($resource); $config = Util::ensureConfig($config); $location = $this->prefix($path); $this->ensureDirectory(dirname($location)); if (!($stream = fopen($location, 'w+'))) { return false; } while (!feof($resource)) { fwrite($stream, fread($resource, 1024), 1024); } if (!fclose($stream)) { return false; } if ($visibility = $config->get('visibility')) { $this->setVisibility($path, $visibility); } return compact('path', 'visibility'); }
/** * Write using a stream * * @param string $path * @param resource $resource * @param mixed $config * * @return array file metadata */ public function writeStream($path, $resource, $config = null) { $config = Util::ensureConfig($config); $options = $this->getOptions($path, array('Body' => $resource), $config); $this->client->putObject($options); return $this->normalizeObject($options); }
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'); }
public function writeStream($path, $resource, $config = null) { $path = Util::normalizePath($path); $this->assertAbsent($path); $config = Util::ensureConfig($config); $config->setFallback($this->getConfig()); if (!is_resource($resource)) { throw new InvalidArgumentException(__METHOD__ . ' expects argument #2 to be a valid resource.'); } if (!($object = $this->adapter->writeStream($path, $resource, $config))) { return false; } $this->cache->updateObject($path, $object, true); $this->cache->ensureParentDirectories($path); return true; }