/** * Write a new file to the source and replica from a stream * * @param string $path * @param resource $resource * @param mixed $config Config object or visibility setting * * @return false|array false on failure file meta data on success */ public function writeStream($path, $resource, $config = null) { if (!$this->source->writeStream($path, $resource, $config)) { return false; } return $this->replica->writeStream($path, $resource, $config); }
/** * {@inheritDoc} */ public function writeStream($path, $resource, Config $config) { $success = $this->adapter->writeStream($path, $resource, $config); if ($success) { $this->cache->delete($this->getCacheKey($path)); } return $success; }
public function it_should_ignore_failed_streamed_writes() { $path = 'path.txt'; $contents = tmpfile(); $config = new Config(); $this->adapter->writeStream($path, $contents, $config)->willReturn(false); $this->writeStream($path, $contents, $config)->shouldBe(false); fclose($contents); }
/** * {@inheritdoc} */ public function writeStream($path, $resource, Config $config) { $result = $this->adapter->writeStream($path, $resource, $config); if ($result !== false) { $contents = false; $this->cache->updateObject($path, $result + compact('path', 'contents'), true); } return $result; }
/** * {@inheritDoc} */ public function writeStream($path, $resource, Config $config) { $this->guardInUploadPath($path); if ($this->adapter->writeStream($path, $resource, $config)) { \Dbafs::addResource($path); return true; } return false; }
/** * {@inheritdoc} */ public function writeStream($path, $resource, array $config = []) { if (!is_resource($resource)) { throw new InvalidArgumentException(__METHOD__ . ' expects argument #2 to be a valid resource.'); } $path = Util::normalizePath($path); $this->assertAbsent($path); $config = $this->prepareConfig($config); Util::rewindStream($resource); return (bool) $this->adapter->writeStream($path, $resource, $config); }
/** * {@inheritdoc} */ public function updateStream($path, $resource, Config $config) { if (!$this->source->updateStream($path, $resource, $config)) { return false; } if ($this->replica->has($path)) { return $this->replica->updateStream($path, $resource, $config); } else { return $this->replica->writeStream($path, $resource, $config); } }
/** * Copies a resource accessible through the fallback adapter to the filesystem abstracted with the main adapter. * * @param $path * @return boolean */ private function portFromFallback($path, $newpath) { $buffer = $this->fallback->readStream($path); if (false === $buffer) { return false; } $result = $this->mainAdapter->writeStream($newpath, $buffer['stream'], new Config()); if (is_resource($buffer['stream'])) { fclose($buffer['stream']); } return false !== $result; }
/** * {@inheritdoc} */ public function writeStream($path, $resource, array $config = []) { $path = Util::normalizePath($path); $this->assertAbsent($path); $config = $this->prepareConfig($config); if (!is_resource($resource)) { throw new InvalidArgumentException(__METHOD__ . ' expects argument #2 to be a valid resource.'); } Util::rewindStream($resource); if (!($object = $this->adapter->writeStream($path, $resource, $config))) { return false; } $this->cache->updateObject($path, $object + ['contents' => false], true); return true; }
/** * {@inheritdoc} */ public function put(string $path, $contents, array $config = []) : bool { $config['visibility'] = $this->parseVisibility($config['visibility'] ?? null) ?: []; $flyConfig = new FlyConfig($config); if (is_resource($contents)) { if ($this->has($path)) { return (bool) $this->driver->updateStream($path, $resource, $flyConfig); } return (bool) $this->driver->writeStream($path, $resource, $flyConfig); } if ($this->has($path)) { return (bool) $this->driver->update($path, $contents, $flyConfig); } return (bool) $this->driver->write($path, $contents, $flyConfig); }
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; }
/** * {@inheritdoc} */ public function writeStream($path, $resource, Config $config) { return $this->adapter->writeStream($this->getPath($path), $resource, $config); }