mirror of
https://github.com/SociallyDev/Spaces-API.git
synced 2025-07-06 04:51:32 -07:00
Merge pull request #31 from bilaltas/master
Recursive option added for deleting folder objects
This commit is contained in:
commit
c9bfe5f30a
2 changed files with 21 additions and 6 deletions
19
README.md
19
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);
|
$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);
|
||||||
|
|
||||||
|
|
|
@ -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,
|
||||||
|
@ -284,7 +288,7 @@ class SpacesConnect {
|
||||||
}
|
}
|
||||||
catch (\Exception $e) {
|
catch (\Exception $e) {
|
||||||
$this->HandleAWSException($e);
|
$this->HandleAWSException($e);
|
||||||
} finally {
|
} finally {
|
||||||
if ($is_file) {
|
if ($is_file) {
|
||||||
fclose($file);
|
fclose($file);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue