/** * {@inheritdoc} */ public function getArchive(JobExecution $jobExecution, $key) { $archives = $this->getArchives($jobExecution); if (!isset($archives[$key])) { throw new \InvalidArgumentException(sprintf('Key "%s" does not exist', $key)); } return $this->filesystem->createStream($archives[$key]); }
/** * Copy stream to storage * * @param Stream $srcStream * @param string $destinationFileName */ protected function copyStreamToStorage(Stream $srcStream, $destinationFileName) { $dstStream = $this->filesystem->createStream($destinationFileName); $srcStream->open(new StreamMode('rb+')); $dstStream->open(new StreamMode('wb+')); while (!$srcStream->eof()) { $dstStream->write($srcStream->read(self::READ_COUNT)); } $dstStream->close(); $srcStream->close(); }
/** * Copy file from local filesystem to attachment storage with new name * * @param string $localFilePath * @param string $destinationFileName */ public function copyLocalFileToStorage($localFilePath, $destinationFileName) { $src = new LocalStream($localFilePath); $dst = $this->filesystem->createStream($destinationFileName); $src->open(new StreamMode('rb+')); $dst->open(new StreamMode('wb+')); while (!$src->eof()) { $dst->write($src->read(100000)); } $dst->close(); $src->close(); }
/** * @param \Gaufrette\FilesystemMap $map * @param \Gaufrette\Filesystem $filesystem * @param \Gaufrette\Stream $stream */ function let($map, $filesystem, $stream) { $filesystem->createStream('filename')->willReturn($stream); $map->get('some')->willReturn($filesystem); $this->setFilesystemMap($map); }
/** * Get a stream from file. * * @param $name * @return \Gaufrette\Stream|\Gaufrette\Stream\InMemoryBuffer */ public function getStream($name) { return $this->filesystem->createStream($name); }