1
0

Add support for replacing an item's data file.

This commit is contained in:
Bharat Mediratta 2010-08-08 01:13:32 -07:00
parent 8562a1abc3
commit cf37aa5ceb
4 changed files with 17 additions and 6 deletions

View File

@ -129,10 +129,16 @@ class Gallery3 {
* @return object Gallery3
*/
public function save() {
$response = Gallery3_Helper::request(
"put", $this->url, $this->token,
array("entity" => array_diff((array)$this->data->entity, $this->original_entity),
"members" => $this->data->members));
$data = array();
$data["entity"] = array_diff((array)$this->data->entity, $this->original_entity);
if (isset($this->data->members)) {
$data["members"] = $this->data->members;
}
if ($this->file) {
$response = Gallery3_Helper::request("put", $this->url, $this->token, $data, $this->file);
} else {
$response = Gallery3_Helper::request("put", $this->url, $this->token, $data);
}
return $this->load();
}

View File

@ -39,13 +39,19 @@ for ($i = 0; $i < 2; $i++) {
->set("type", "photo")
->set("name", "Sample Photo.png")
->set("title", "Sample Photo")
->set_file("gallery.png")
->set_file("test1.png")
->create($album->url, $auth);
alert("Uploaded photo: <b>{$photo->url}</b>");
}
$album->load();
alert("Album members: <b>" . join(", ", $album->data->members) . "</b>");
alert("Replace the data file");
$photo->set_file("test2.png")
->save();
$comment = Gallery3::factory()
->set("item", $album->data->members[0])
->set("type", "comment")
@ -93,7 +99,6 @@ $tag_relationship2->delete();
$tag->load();
alert("1 remaining tag: <b>{$tag->data->relationships->items->members[0]}</b>");
alert("Delete the album and tag");
$album->delete();
$tag->delete();

View File

Before

Width:  |  Height:  |  Size: 22 KiB

After

Width:  |  Height:  |  Size: 22 KiB

BIN
client/test2.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.3 KiB