php-opencloud / openstack

PHP SDK for OpenStack clouds
Apache License 2.0
221 stars 148 forks source link

Setting X-Delete-After and other system metadata on objectStore #249

Open tarik23 opened 6 years ago

tarik23 commented 6 years ago

I need to set X-Delete-At or X-Delete-After for already existing Object in storage. I tried to do it using $openstack->objectStoreV1() ->getContainer($containerName) ->getObject($fileName)->mergeMetadata([ 'X-Delete-After' => "10", ]);

AND

I used: $openstack->objectStoreV1() ->getContainer($containerName) ->getObject($fileName) ->mergeMetadata([ 'deleteAfter' => '100', ]);

But it sets X-Object-Meta-deleteAfter param, and not the X-Delete-After metadata value.

So my question is how to set them?

Additionaly Official docs https://developer.openstack.org/api-ref/object-store/?expanded=get-object-content-and-metadata-detail says that "In addition to the custom metadata (like X-Object-Meta-name), you can update the Content-Type, Content-Encoding, Content-Disposition, and X-Delete-At system metadata items. However you cannot update other system metadata, such as Content-Length or Last-Modified."

But I cant find this ability in php-opencloud.

haphan commented 6 years ago

@tarik23 Thanks for reporting this bug.

Indeed ->mergeMetadata is not meant to update system metadata like X-Delete-After or X-Delete-At

in #250, I've added a generic method $object->update for this purpose. Now you can update custom metadata and set X-Delete-At at the same time.

$obj->update(['deleteAfter' => 3600, 'metadata' => ['foo' => 'bar']]);

Do check-out branch objectstorage-meta and let me know if it works for you.

austin1030 commented 3 years ago

@tarik23 Thanks for reporting this bug.

Indeed ->mergeMetadata is not meant to update system metadata like X-Delete-After or X-Delete-At

in #250, I've added a generic method $object->update for this purpose. Now you can update custom metadata and set X-Delete-At at the same time.

$obj->update(['deleteAfter' => 3600, 'metadata' => ['foo' => 'bar']]);

Do check-out branch objectstorage-meta and let me know if it works for you.

How come I can't call $obj->update on v3?