From d9950b728bdbe0b1dbe47a2cf06172eda7f30895 Mon Sep 17 00:00:00 2001 From: Kirill Kasyanov Date: Sat, 25 Jan 2020 15:54:31 +0400 Subject: [PATCH] Replace function --- src/AbstractBucket.php | 9 +++++++++ src/drivers/FileSystemDriver.php | 7 +++++++ 2 files changed, 16 insertions(+) diff --git a/src/AbstractBucket.php b/src/AbstractBucket.php index 76cfd80..556de32 100644 --- a/src/AbstractBucket.php +++ b/src/AbstractBucket.php @@ -58,6 +58,15 @@ abstract public function getSource($path); */ abstract public function delete($path); + /** + * Замена содержимого файла. + * + * @param $path + * @param $binary + * @return boolean + */ + abstract public function replace($path, $binary); + /** * Равномерно и однозначно извлекает один из $baseUrls по переданному $path. * @param array|string $baseUrls - массив diff --git a/src/drivers/FileSystemDriver.php b/src/drivers/FileSystemDriver.php index 61d4704..fe6681b 100644 --- a/src/drivers/FileSystemDriver.php +++ b/src/drivers/FileSystemDriver.php @@ -111,4 +111,11 @@ public function delete($path) return @unlink($filePath); } + /** + * @inheritdoc + */ + public function replace($path, $binary) + { + return file_put_contents($this->basePath . $path, $binary); + } } \ No newline at end of file