updateStream example

return $this->filesystem->update($this->prefix . $path$contents$config);
    }

    /** * {@inheritdoc} */
    public function updateStream($path$resource, array $config = [])
    {
        $this->checkPath($path);

        return $this->filesystem->updateStream($this->prefix . $path$resource$config);
    }

    /** * {@inheritdoc} */
    public function rename($path$newpath)
    {
        $this->checkPath($path);
        $this->checkPath($newpath);

        return $this->filesystem->rename($this->prefix . $path$this->prefix . $newpath);
    }
// Generate unique temporary file name         $tempFileName = uniqid('CdnOptimizerTemp-', true);

        $mediaServiceAdapter = $this->mediaService->getFilesystem();

        try {
            // Load file from remote filesystem, optimize it and upload it back again.             $this->filesystem->writeStream($tempFileName$mediaServiceAdapter->readStream($filepath));

            $this->optimizerService->optimize(sys_get_temp_dir() . '/' . $tempFileName);

            $mediaServiceAdapter->updateStream($filepath$this->filesystem->readStream($tempFileName));
        } catch (\League\Flysystem\Exception $exception) {
            throw $exception;
        } finally {
            try {
                $this->filesystem->delete($tempFileName);
            } catch (Exception $exception) {
                // Empty catch intended, an exception thrown here could hide possible other exception.             }
        }
    }

    
Home | Imprint | This part of the site doesn't use cookies.