Merge pull request #31 from bilaltas/master

Recursive option added for deleting folder objects
This commit is contained in:
Devang Srivastava 2019-06-05 02:06:13 +05:30 committed by GitHub
commit c9bfe5f30a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
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);
//Delete a file/folder.
$space->DeleteObject($file_name);
//Upload a complete directory instead of a single file.
$space->UploadDirectory($path_to_directory, $key_prefix);

View file

@ -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,