123456789101112131415161718192021222324252627282930313233343536373839404142434445464748 |
- <?php
- require_once('request.php');
- require_once('../arav_up_inclu/base64codec.php');
- require_once('../arav_up_inclu/injectors.php');
- class arkiwiRequestPostModifyMetadata extends arkiwiRequest
- {
- private $item64 = null;
- private $metadata = Array();
- private $path = null;
- public function __construct($request) {
- parent::__construct($request);
- $extra = $this->getRequestExtra();
- $this->item64 = $extra[0];
- $this->path = "/".decoder($extra[0]);
- }
- public function run() {
- if($this->request['method'] != 'POST') {
- $this->setBodyError(500, "arkiwiRequestPostModifyMetadata: POST method required.");
- return;
- }
- $input = file_get_contents('php://input');
- $obj = json_decode($input);
- if (!is_array($obj)) {
- $this->setBodyError(400, "Wrong json input");
- return;
- }
- foreach($obj as $kv) {
- if (isset($kv->name) && isset($kv->value)) {
- $this->addKeyValue($kv->name, $kv->value);
- }
- }
- store_md_array($this->metadata, $this->path);
- $this->setCode(201);
- $this->setBodyJSON(true);
- }
- private function addKeyValue($k, $v) {
- $this->metadata[$k] = $v;
- }
- }
|