New config param: overwrite_on_upload

This commit is contained in:
Milos Stojanovic
2020-03-23 13:37:54 +01:00
parent 0765958729
commit 8330fa86bc
7 changed files with 43 additions and 6 deletions

View File

@@ -161,12 +161,16 @@ class Filesystem implements Service
return $this->storage->rename($from, $to);
}
public function store(string $path, string $name, $resource): bool
public function store(string $path, string $name, $resource, bool $overwrite = false): bool
{
$destination = $this->joinPaths($this->applyPathPrefix($path), $name);
while ($this->storage->has($destination)) {
$destination = $this->upcountName($destination);
if ($overwrite) {
$this->deleteFile($destination);
} else {
$destination = $this->upcountName($destination);
}
}
return $this->storage->putStream($destination, $resource);