/** * {@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(); }
/** * 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_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); }
/** * 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)); }
/** * Get a filesystem instance. * * @param string $name * @return \Illuminate\Contracts\Filesystem\Filesystem * @static */ public static function disk($name = null) { return \Illuminate\Filesystem\FilesystemManager::disk($name); }
/** * returns disk filesystem * * @param string $name disk name * @return \Illuminate\Contracts\Filesystem\Filesystem */ protected function getDisk($name) { return $this->filesystem->disk($name); }
/** * Remover todos os convites. * @return bool */ public function delete() { $this->storage->disk()->deleteDirectory('/invites'); return true; }