/** * {@inheritdoc} */ public function getAssetConversionUrl(EmbridgeAssetEntityInterface $asset, $application_id, $conversion) { $settings = $this->configFactory->get('embridge.settings'); $uri = $settings->get('uri'); $url = $uri . '/' . $application_id . '/views/modules/asset/downloads/preview/' . $conversion . '/' . $asset->getSourcePath() . '/thumb.jpg'; return $url; }
/** * {@inheritdoc} */ public function upload(EmbridgeAssetEntityInterface $asset, array $metadata = []) { $this->login(); $file_path = $this->fileSystem->realpath($asset->getSourcePath()); $filename = $asset->getFilename(); // Sanitize metadata values. $metadata = array_filter($metadata, 'is_scalar'); if (isset($metadata['libraries'])) { // The libraries value won't stick unless it is a string. $metadata['libraries'] = (string) $metadata['libraries']; } // Build the main request data. $json_values = ['description' => $filename]; $json_values = array_merge($json_values, $metadata); $json_request = $this->jsonEncoder->encode($json_values); $body = ['multipart' => [['name' => 'jsonrequest', 'contents' => $json_request], ['name' => 'file', 'contents' => file_get_contents($file_path), 'filename' => $filename]]]; $response_body = $this->doRequest(self::EMBRIDGE_UPLOAD_PATH_DEFAULT, $body); $asset->setAssetId($response_body['data']['id']); $asset->setSourcePath($response_body['data']['sourcepath']); return $asset; }