Using Rackspace cloud files as a backup repository but new to their PHP API. I want to delete files past a certail age but having difficulty returning the last_modified date using the api.
$container = $conn->get_container('tmp');
$files = $container->list_objects();
foreach ($files as $file) {
echo $file; // echo filename
echo $file->last_modified(); // this syntax is incorrect
}
list_objects
returns an array of strings, the names of the objects. You can also get PHP objects that allow you to use OOP to do things to those objects. So changing as little of your code as possible, we can convert the strings to objects:
$container = $conn->get_container('tmp');
$files = $container->list_objects();
foreach ($files as $file) {
echo $file; // echo filename
$file_obj = $container->get_object($file);
echo $file_obj->last_modified;
}
A little faster, just get an array of objects instead:
$container = $conn->get_container('tmp');
$files = $container->get_objects();
foreach ($files as $file) {
echo $file->name; // echo filename
echo $file->last_modified;
}
Node that code has not been tested, but should get you pretty close to something that works.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.