option('disk') ?: config('manager.media.disk')); $disk = Storage::disk($name); $location = 'manager-check/'.bin2hex(random_bytes(6)).'.txt'; $content = 'manager storage check '.now()->toIso8601String(); $this->line("Disk: {$name}"); try { $step = 'write'; if (! $disk->put($location, $content)) { $this->components->error('The file could not be written. See the log of the app for the reason.'); return self::FAILURE; } $this->components->info('Written.'); $step = 'read'; $back = $disk->get($location); if ($back !== $content) { $this->components->error('What was read back is not what was written.'); return self::FAILURE; } $this->components->info('Read back: the same.'); $step = 'delete'; if (! $disk->delete($location)) { $this->components->error("The test file could not be deleted: {$location}"); return self::FAILURE; } $this->components->info('Deleted.'); } catch (MediaStorageException|Throwable $e) { $this->components->error("Could not {$step}: ".$e->getMessage()); return self::FAILURE; } $this->components->info('The storage works.'); return self::SUCCESS; } }