diff --git a/lib/utils/temporaryphoto.php b/lib/utils/temporaryphoto.php index 74348228..38876e4e 100644 --- a/lib/utils/temporaryphoto.php +++ b/lib/utils/temporaryphoto.php @@ -24,6 +24,8 @@ namespace OCA\Contacts\Utils; /** * This class is used for getting a temporary contact photo for cropping. + * + * Sub-classes must override __construct() and processImage() */ class TemporaryPhoto { diff --git a/lib/utils/temporaryphoto/contact.php b/lib/utils/temporaryphoto/contact.php index 42fb7e9b..3e744221 100644 --- a/lib/utils/temporaryphoto/contact.php +++ b/lib/utils/temporaryphoto/contact.php @@ -23,12 +23,12 @@ namespace OCA\Contacts\Utils\TemporaryPhoto; use OCA\Contacts\Contact as ContactObject, - OCA\Contacts\Utils\TemporaryPhoto as AbstractTemporaryPhoto; + OCA\Contacts\Utils\TemporaryPhoto as BaseTemporaryPhoto; /** * This class loads the PHOTO or LOGO property from a contact. */ -class Contact extends AbstractTemporaryPhoto { +class Contact extends BaseTemporaryPhoto { /** * The Contact object to load the image from diff --git a/lib/utils/temporaryphoto/filesystem.php b/lib/utils/temporaryphoto/filesystem.php index 3e6aa937..a717379c 100644 --- a/lib/utils/temporaryphoto/filesystem.php +++ b/lib/utils/temporaryphoto/filesystem.php @@ -23,12 +23,13 @@ namespace OCA\Contacts\Utils\TemporaryPhoto; use OCA\Contacts\Contact as ContactObject, - OCA\Contacts\Utils\TemporaryPhoto as AbstractTemporaryPhoto; + OCA\Contacts\Utils\TemporaryPhoto as BaseTemporaryPhoto, + OCP\AppFramework\Http; /** * This class loads an image from the virtual file system. */ -class FileSystem extends AbstractTemporaryPhoto { +class FileSystem extends BaseTemporaryPhoto { /** * The virtual file system path to load the image from @@ -54,10 +55,17 @@ class FileSystem extends AbstractTemporaryPhoto { * Load the image. */ protected function processImage() { - $localpath = \OC\Files\Filesystem::getLocalFile($this->path); + $localPath = \OC\Files\Filesystem::getLocalFile($this->path); + + if (!file_exists($localPath)) { + throw new \Exception( + 'The file does not exist: ' . $localPath, + Http::STATUS_NOT_FOUND + ); + } $this->image = new \OCP\Image(); - $this->image->loadFromFile($localpath); + $this->image->loadFromFile($localPath); } } \ No newline at end of file diff --git a/lib/utils/temporaryphoto/uploaded.php b/lib/utils/temporaryphoto/uploaded.php index 7978297a..e935fcca 100644 --- a/lib/utils/temporaryphoto/uploaded.php +++ b/lib/utils/temporaryphoto/uploaded.php @@ -23,7 +23,7 @@ namespace OCA\Contacts\Utils\TemporaryPhoto; use OCA\Contacts\Contact as ContactObject, - OCA\Contacts\Utils\TemporaryPhoto as AbstractTemporaryPhoto, + OCA\Contacts\Utils\TemporaryPhoto as BaseTemporaryPhoto, OCP\IRequest, OCP\AppFramework\Http, OCP\Image; @@ -31,7 +31,7 @@ use OCA\Contacts\Contact as ContactObject, /** * This class loads an image from the virtual file system. */ -class Uploaded extends AbstractTemporaryPhoto { +class Uploaded extends BaseTemporaryPhoto { /** * The request to read the data from