rename ( $path_from, $path_to )

Renames a file or directory. This method is called in response to rename().

Access

public

Parameters

Parameter

Type

Required

Description

$path_from

string

Required

The URL to the current file.

$path_to

string

Required

The URL which the $path_from should be renamed to.

Returns

Type

Description

boolean

Returns true on success or false on failure.

Source

Method defined in extensions/s3streamwrapper.class.php | Toggle source view (22 lines) | View on GitHub

public function rename($path_from, $path_to)
{
    list($protocol, $from_bucket_name, $from_object_name) = $this->parse_path($path_from);
    list($protocol, $to_bucket_name, $to_object_name) = $this->parse_path($path_to);

    $copy_response = $this->client($protocol)->copy_object(
        array('bucket' => $from_bucket_name, 'filename' => $from_object_name),
        array('bucket' => $to_bucket_name,   'filename' => $to_object_name  )
    );

    if ($copy_response->isOK())
    {
        $delete_response = $this->client($protocol)->delete_object($from_bucket_name, $from_object_name);

        if ($delete_response->isOK())
        {
            return true;
        }
    }

    return false;
}

Copyright © 2010–2013 Amazon Web Services, LLC


Feedback