trafalgar
trafalgar

Reputation: 736

how to upload a Cloud File on Rackspace and set delete at or file expiry?

I'm on a local XAMPP setup and I can upload a file ok, but I need to set an expiry or delete time.

This does not work (no PHP errors but the file is still there on the Rackspace, web admin page):

$obj->Create(
    array('name'=>'file.txt',
        'content_type'=>'application/octet-stream',
        'extra_headers'=>'X-Delete-After: 300'
    ), 'd:\file.txt');

This does not work either:

 $obj->Create(
     array('name'=>'fdedd.txt.3',
        'content_type'=>'application/octet-stream',
        'X-Delete-After'=>'300'
     ), 'd:\fdedd.bb.txt');

Giving a:

Fatal error: Uncaught exception 'OpenCloud\ObjectStore\UnknownParameterError' with message 'Unrecognized parameter [X-Delete-After] for object

Upvotes: 0

Views: 561

Answers (1)

trafalgar
trafalgar

Reputation: 736

There is an issue with the PHP api.

To add extra headers to delete a file after X seconds, you need to do this in this order:

$obj = $container->DataObject();
$obj->extra_headers['X-Delete-After'] = 86400;
$obj->Create(array('name'=>'Name', 'content_type'=>'text/html'), $FILENAME);

Upvotes: 1

Related Questions