1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374 |
- <?php
- namespace OCA\DAV\Avatars;
- use OCP\IAvatar;
- use Sabre\DAV\File;
- class AvatarNode extends File {
-
- public function __construct(
- private $size,
- private $ext,
- private $avatar,
- ) {
- }
-
- public function getName() {
- return "$this->size.$this->ext";
- }
- public function get() {
- $image = $this->avatar->get($this->size);
- $res = $image->resource();
- ob_start();
- if ($this->ext === 'png') {
- imagepng($res);
- } else {
- imagejpeg($res);
- }
- return ob_get_clean();
- }
-
- public function getContentType() {
- if ($this->ext === 'png') {
- return 'image/png';
- }
- return 'image/jpeg';
- }
- public function getETag() {
- return $this->avatar->getFile($this->size)->getEtag();
- }
- public function getLastModified() {
- return $this->avatar->getFile($this->size)->getMTime();
- }
- }
|