diff --git a/README.md b/README.md index dabbfe9..5407245 100644 --- a/README.md +++ b/README.md @@ -53,6 +53,21 @@ All available options: +  + + +### Deleting Files/Folders +```php + +$file_name = "image.png"; + +$space->DeleteObject($file_name); +``` +All available options: +###### DeleteObject(REQUIRED FILE OR FOLDER TO DELETE, OPTIONAL RECURSIVE (false|true)); + + +   @@ -101,10 +116,6 @@ $space->DoesObjectExist($file_name); $file_info = $space->GetObject($file_name); -//Delete a file/folder. -$space->DeleteObject($file_name); - - //Upload a complete directory instead of a single file. $space->UploadDirectory($path_to_directory, $key_prefix); diff --git a/spaces.php b/spaces.php index 74789b4..8494bf4 100644 --- a/spaces.php +++ b/spaces.php @@ -238,8 +238,12 @@ class SpacesConnect { /* Deletes an object. */ - function DeleteObject($file_path = "") { + function DeleteObject($file_path = "", $recursive = false) { try { + if ($recursive) return $this->ObjReturn($this->client->deleteMatchingObjects( + $this->space, + $file_path + )); return $this->ObjReturn($this->client->deleteObject([ 'Bucket' => $this->space, 'Key' => $file_path, @@ -284,7 +288,7 @@ class SpacesConnect { } catch (\Exception $e) { $this->HandleAWSException($e); - } finally { + } finally { if ($is_file) { fclose($file); }