/** * {@inheritdoc} */ public function getTimestamp($key) { if ($this->filesystem->exists($key) === false) { return 0; } return $this->filesystem->lastModified($key); }
/** * {@inheritdoc} */ public function getUrl() { if (!$this->isPubliclyAccessible()) { throw MediaUrlException::cloudMediaNotPubliclyAccessible($this->media->disk); } return $this->filesystem->disk($this->media->disk)->url($this->media->getDiskPath()); }
public function __construct() { $this->manager = app('filesystem'); $this->storage_local = $this->manager->disk('local'); $this->storage_cloud = $this->manager->disk(config('filesystems.cloud')); $this->storage_tmp = $this->manager->disk('tmp'); $this->setStorage(); }
/** * Execute the console command. * * @return mixed */ public function handle(Config $config, Storage $storage) { $conn = $config->get('laravel-db-commands.backup_db_conn'); $db = $config->get("database.connections.{$conn}"); $dump_dest = $config->get('laravel-db-commands.backup_dump_destination'); $backup_disk_name = $config->get('laravel-db-commands.backup_disk'); $backup_disk = $storage->disk($backup_disk_name); $backup_name = $db['database'] . '-' . time() . '.sql.gz'; $tmp_file = "{$dump_dest}/{$backup_name}"; $this->dumpMysqlDatabase($db, $tmp_file); $this->uploadDumpToDisk($backup_disk, $backup_name, $tmp_file); }
/** * Handle the hook. * * @param \Docit\Core\Project $project * @return void */ public function handle(Project $project) { if (!$project->config('enable_filesystem_hook')) { $project->setFiles(new LocalFilesystem()); } $disk = $project->config('default_filesystem_disk'); $settings = $project->config('filesystem_hook_settings'); if (!isset($settings[$disk])) { return; } $files = $this->fsm->disk($disk); if (isset($files)) { $project->setFiles($files); $project->setPath($project->getName()); } }
/** * Generate a list of all files in the specified directory. * @param atring $disk * @param string $directory * @param bool $recursive * @return array */ protected function listFiles($disk, $directory = '', $recursive = true) { if ($recursive) { return $this->filesystem->disk($disk)->allFiles($directory); } else { return $this->filesystem->disk($disk)->files($directory); } }
/** * Move the file to a new location on disk. * * Will invoke the `save()` method on the model after the associated file has been moved to prevent synchronization errors * @param \Plank\Mediable\Media $media * @param string $directory directory relative to disk root * @param string $name filename. Do not include extension * @return void * @throws \Plank\Mediable\Exceptions\MediaMoveException If attempting to change the file extension or a file with the same name already exists at the destination */ public function move(Media $media, $directory, $filename = null) { $storage = $this->filesystem->disk($media->disk); if ($filename) { $filename = $this->removeExtensionFromFilename($filename, $media->extension); } else { $filename = $media->filename; } $directory = trim($directory, '/'); $target_path = $directory . '/' . $filename . '.' . $media->extension; if ($storage->has($target_path)) { throw MediaMoveException::destinationExists($target_path); } $storage->move($media->getDiskPath(), $target_path); $media->filename = $filename; $media->directory = $directory; $media->save(); }
/** * Execute the console command. * * @return mixed */ public function handle(Config $config, Storage $storage) { $conn = $config->get('laravel-db-commands.backup_db_conn'); $db = $config->get("database.connections.{$conn}"); $dump_dest = $config->get('laravel-db-commands.backup_dump_destination'); $backup_disk = $config->get('laravel-db-commands.backup_disk'); $db_host = $db['host']; $db_name = $db['database']; $db_user = $db['username']; $db_pass = $db['password']; $backup_name = $db_name . '-' . time() . '.sql.gz'; $tmp_file = "{$dump_dest}/{$backup_name}"; $this->info("Generating Backup File"); $output = shell_exec("mysqldump -h {$db_host} -u {$db_user} -p{$db_pass} {$db_name} | gzip > {$tmp_file}"); $this->info($output); $this->info("Uploading database to S3"); $s3 = $storage->disk($backup_disk); $s3->put($backup_name, file_get_contents($tmp_file)); }
public function createLocalDriver(array $config) { $permissions = isset($config['permissions']) ? $config['permissions'] : []; $links = Arr::get($config, 'links') === 'skip' ? DistributedAdapter::SKIP_LINKS : DistributedAdapter::DISALLOW_LINKS; if (array_key_exists('distributed', $config)) { if ($config['distributed']) { return $this->adapt($this->createDistributedFilesystem(new DistributedAdapter($config['root'], LOCK_EX, $links, $permissions), $config)); } } return parent::createLocalDriver($config); }
/** * Register a custom driver creator Closure. * * @param string $driver * @param \Closure $callback * @return $this * @static */ public static function extend($driver, $callback) { return \Illuminate\Filesystem\FilesystemManager::extend($driver, $callback); }
/** * {@inheritdoc} */ public function exists($name) { return $this->filesystem->exists($this->getTemplatePath($name)); }
/** * returns disk filesystem * * @param string $name disk name * @return \Illuminate\Contracts\Filesystem\Filesystem */ protected function getDisk($name) { return $this->filesystem->disk($name); }
/** * {@inheritdoc} */ public function createRackspaceDriver(array $config) { if ($this->skipOverride()) { $adapter = parent::createRackspaceDriver($config); } else { $adapter = $this->adapt($this->createFlysystem(parent::createRackspaceDriver($config)->getAdapter(), $config)); } return $adapter; }
/** * Remover todos os convites. * @return bool */ public function delete() { $this->storage->disk()->deleteDirectory('/invites'); return true; }