/** * Upload a single file. * * @param \Symfony\Component\HttpFoundation\File\UploadedFile $file * * @param string $target * @return string */ protected function uploadSingleFile($file, $target = null) { $filename = uniqid() . '.' . $file->getClientOriginalExtension(); $filename = $target ? $target . '/' . $filename : $filename; $content = file_get_contents($file->getRealPath()); $this->flysystem->write($filename, $content); return cloudfront_asset($filename); }
/** * Make a new store. * * @param array $config * * @throws \InvalidArgumentException * * @return \AltThree\Storage\Stores\StoreInterface */ public function make(array $config) { $config = $this->getConfig($config); $store = new FlysystemStore($this->flysystem->connection($config['main'])); if ($config['fallback']) { $store = new FallbackStore($store, new FlysystemStore($this->flysystem->connection($config['fallback']))); } if ($config['compression']) { $store = new CompressingStore($store, $this->compressor); } if ($config['encryption']) { if ($config['compression']) { throw new InvalidArgumentException('Compression cannot be enabled at the same time as encryption.'); } $store = new EncryptingStore($store, $this->encrypter); } if ($cache = $config['cache']) { $store = new CachingStore($store, $this->cache->store($cache === true ? null : $cache)); } return $store; }
/** * Get the config instance. * * @return \Illuminate\Contracts\Config\Repository * @static */ public static function getConfig() { //Method inherited from \GrahamCampbell\Manager\AbstractManager return \GrahamCampbell\Flysystem\FlysystemManager::getConfig(); }
/** * Get the cache client. * * @param string[] $config * * @return \League\Flysystem\AdapterInterface */ protected function getClient(array $config) { $name = array_get($config, 'adapter'); $config = $this->manager->getConnectionConfig($name); return $this->manager->getFactory()->createAdapter($config); }
/** * @param Image $image * @param string $path * * @return bool */ public function save(Image $image, $path) { return $this->flysystem->put($path, $image->encode()); }
/** * @param string $path * @return bool */ public function pathExists($path) { return $this->flysystem->has($path); }