php - Updating Modifying File To Rackspace Cloud


How can I update files to rackspace api? I've tried several things like the code below, and it only works if I upload the image twice. Is there anyway of doing this?

public function updateRackSpaceFile($file_name, $file_location, $container_name='photos'){

        $conn = new \CF_Connection($auth);
        $container_object = $conn->get_container($container_name);
        $object=$container_object -> get_object($file_name);
        $object ->load_from_filename($file_location);



I don't think you need to do a get on the object. Simply create a new object and upload. It will replace the object with the same name.

    $fname = basename('image.jpg');
    $md5 = md5_file($fname);
    $container = $conn->get_container('my_container');
    $o2 = $container->create_object($fname);
    $o2->content_type = "image/jpeg";
    $result = $o2->load_from_filename($fname);
    assert('$o2->getETag() == $md5');

People are also looking for solutions to the problem: php - Why Does This Perform Better?


Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.