Recursive option added for deleting folder objects

This commit is contained in:
Bilal TAS 2019-06-03 08:52:35 +03:00
parent 12b4f6a627
commit 267ba3e4a6
2 changed files with 21 additions and 6 deletions

View file

@ -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); $file_info = $space->GetObject($file_name);
//Delete a file/folder.
$space->DeleteObject($file_name);
//Upload a complete directory instead of a single file. //Upload a complete directory instead of a single file.
$space->UploadDirectory($path_to_directory, $key_prefix); $space->UploadDirectory($path_to_directory, $key_prefix);

View file

@ -238,8 +238,12 @@ class SpacesConnect {
/* /*
Deletes an object. Deletes an object.
*/ */
function DeleteObject($file_path = "") { function DeleteObject($file_path = "", $recursive = false) {
try { try {
if ($recursive) return $this->ObjReturn($this->client->deleteMatchingObjects(
$this->space,
$file_path
));
return $this->ObjReturn($this->client->deleteObject([ return $this->ObjReturn($this->client->deleteObject([
'Bucket' => $this->space, 'Bucket' => $this->space,
'Key' => $file_path, 'Key' => $file_path,