-
Notifications
You must be signed in to change notification settings - Fork 248
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add delete object method in the container of ObjectStore. #651
Conversation
@Ducatel This is a way around this, but it's not well documented: $container = $objectStoreService->getContainer('{containerName}');
$object = $container->object();
$object->setName('{objectName}');
$object->delete(); Your way is easier though |
@jamiehannaford Your way can be added in the documentation. EDIT:
I find another way with $container = $objectStoreService->getContainer('{containerName}');
$partialObject = $container->getPartialObject('objectName'); // Faster than getObject
$partialObject->delete(); EDIT 2: Ok, I found what you explain. It's also working ;) $container = $objectStoreService->getContainer('{containerName}');
$object = new \OpenCloud\ObjectStore\Resource\DataObject($container);
$object->setName('{objectName}');
$object->delete(); |
Hi, thanks ;) |
} | ||
} | ||
return false; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My problem with this is what happens if a 500
or 403
is returned? All the user will get is false
. One option would be to return nothing for success, and an exception for failure. So it could just be:
$this->getClient()
->delete($this->getUrl($name))
->send();
What do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes it will be more consistent with the rest of API.
If the code change, we need to update unit test of this function.
Sorry this took so long to get to. I've left 1 comment that requires a bit of feedback before we continue |
No problem. I will make the update |
My fix seems good for you ? |
*/ | ||
public function deleteObject($name) | ||
{ | ||
$response = $this->getClient() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need to have $response =
since the variable is never used
@Ducatel Thanks for pushing these changes. There's just two very minor issues left before we can merge. In terms of PHP 7, I'm pretty sure the build will always break - so not sure there's much point adding it to the matrix. Same with HHVM. If it passes, though, I'm happy to add. |
arf, I forgot to delete theses variables, my apologies... I use PHP7 and HHVM so, I will probably check if all tests are passing on theses environments (and make some fix if necessary) |
Add delete object method in the container of ObjectStore.
Sounds good 👍 Feel free to submit a PR if PHP 7 or HHVM works |
Ok, no problem. EDIT: Ok, so the version is released ;) |
@Ducatel yep, just now 😄 |
You can still submit a PR for the Travis builds and I'll increment to v1.16.1 |
Hi everybody,
I add deleteObject method in the container class of object storage API.
This method is faster than the previous way to delete an object from the object storage.
According to the documentation, previously you must download the object and after delete it.
The first step isn't always relevant (Can generate some performance issue if the object is big).
Now you can delete it without downloaded it.
Have fun ;)