public final function create_video() { if (!current_user_can('upload_files')) { wp_send_json_error(); } $filename = isset($_REQUEST['filename']) ? $_REQUEST['filename'] : ''; $video = \Ekko\Core\Services\Hub::singleton()->create_video($filename, get_current_blog_id()); if ($video) { //Add S3 object key for upload to S3 $video['key'] = \GTO\Framework\Util\UUID::v4() . '/' . $filename; wp_send_json_success($this->normalize_video($video)); } wp_send_json_error(); }
/** * Fetches a unique ID for a resource * * @param object $item * * @return string */ private function get_resource_id($item) { switch ($item->type) { case 'file': $item->key = "file:{$item->post_id}"; break; case 'ecv': $item->key = "ecv:{$item->ecv_id}"; break; case 'uri': $item->key = $item->uri; break; } foreach ($this->resource_map as $resource) { if ($resource->key == $item->key) { return $resource->id; } } $item->id = \GTO\Framework\Util\UUID::v4(); $this->resource_map[] = $item; return $item->id; }