Add support for replacing an item's data file.
This commit is contained in:
parent
8562a1abc3
commit
cf37aa5ceb
@ -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();
|
||||
}
|
||||
|
||||
|
@ -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();
|
||||
|
Before Width: | Height: | Size: 22 KiB After Width: | Height: | Size: 22 KiB |
BIN
client/test2.png
Normal file
BIN
client/test2.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 8.3 KiB |
Reference in New Issue
Block a user