/** * createFilePreview * * Return a file preview from Amazon S3. * * ### Example: * * $options * $options['filename'] * $options['title'] * $options['description'] * $options['originalFilename'] * * $path is the path of the image in the S3 bucket * * @param string $path * @param string $site * @param array $options * @return string */ public function createFilePreview($path, $site, array $options = []) { $html = ''; if ($path != null && $path != '') { try { $plainUrl = $this->getObjectUrl($site, $path); //$this->_s3Client->getObjectUrl($bucketName, $path, '+10 minutes'); $fileName = $options['filename']; if (WRUtils::guessKindOfFile($fileName) == 'image') { $html .= "<div class=\"file-selectable\" my-data-key=\"" . $options['id'] . "\" title=\"" . $options['title'] . "\">"; $html .= "<img style='height:120px' src='" . $plainUrl . "' class='file-preview-image' alt='" . $options['originalFilename'] . "' title='" . $options['originalFilename'] . "'>"; $html .= "</div>"; } else { $html .= "<div class=\"file-selectable\" my-data-key=\"" . $options['id'] . "\" title=\"" . $options['title'] . "\">"; $html .= WRUtils::getPreviewFileIcon($fileName); $html .= "</div>"; } } catch (\Exception $e) { $html .= "No preview!"; } } return $html; }
private function preparePath($path) { // if complete path, it's ok! if (WRUtils::startsWith($path, "//") || WRUtils::startsWith($path, "http")) { return $path; } if (!WRUtils::startsWith($path, "/")) { $path = '/' . $path; } return $this->proxyBasePath . $path; }