diff --git a/modules/gallery/helpers/data_rest.php b/modules/gallery/helpers/data_rest.php index ca5acb4a31..e45a46453a 100644 --- a/modules/gallery/helpers/data_rest.php +++ b/modules/gallery/helpers/data_rest.php @@ -58,18 +58,6 @@ static function get($request) { return $result; } - static function put($request) { - $item = rest::resolve($request->url); - access::required("edit", $item); - - if ($item->is_album()) { - throw new Rest_Exception("Bad Request", 400, array("errors" => array("type" => "invalid"))); - } - - $item->set_data_file($request->file); - $item->save(); - } - static function resolve($id) { $item = ORM::factory("item", $id); if (!access::can("view", $item)) { diff --git a/modules/gallery/helpers/item_rest.php b/modules/gallery/helpers/item_rest.php index 6869181d19..10f9e16af4 100644 --- a/modules/gallery/helpers/item_rest.php +++ b/modules/gallery/helpers/item_rest.php @@ -126,6 +126,12 @@ static function put($request) { } } } + + // Replace the data file, if required + if (($item->is_photo() || $item->is_movie()) && isset($request->file)) { + $item->set_data_file($request->file); + } + $item->save(); if (isset($request->params->members) && $item->sort_column == "weight") {