Built-in File Manager (#458)

This commit is contained in:
Saeed Vaziry
2025-02-16 19:56:21 +01:00
committed by GitHub
parent 75e554ad74
commit e2b9d18a71
17 changed files with 907 additions and 29 deletions

View File

@ -263,10 +263,14 @@ public function download(string $url, string $path): string
/**
* @throws SSHError
*/
public function unzip(string $path): string
public function extract(string $path, ?string $destination = null, ?string $user = null): void
{
return $this->server->ssh()->exec(
'unzip '.$path
$this->server->ssh($user)->exec(
view('ssh.os.extract', [
'path' => $path,
'destination' => $destination,
]),
'extract'
);
}
@ -304,9 +308,9 @@ public function resourceInfo(): array
/**
* @throws SSHError
*/
public function deleteFile(string $path): void
public function deleteFile(string $path, ?string $user = null): void
{
$this->server->ssh()->exec(
$this->server->ssh($user)->exec(
view('ssh.os.delete-file', [
'path' => $path,
]),
@ -314,6 +318,33 @@ public function deleteFile(string $path): void
);
}
/**
* @throws SSHError
*/
public function ls(string $path, ?string $user = null): string
{
return $this->server->ssh($user)->exec('ls -la '.$path);
}
/**
* @throws SSHError
*/
public function write(string $path, string $content, ?string $user = null): void
{
$this->server->ssh($user)->write(
$path,
$content
);
}
/**
* @throws SSHError
*/
public function mkdir(string $path, ?string $user = null): string
{
return $this->server->ssh($user)->exec('mkdir -p '.$path);
}
private function deleteTempFile(string $name): void
{
if (Storage::disk('local')->exists($name)) {