. * */ namespace OCA\Contacts\Utils\TemporaryPhoto; use OCA\Contacts\Contact as ContactObject, OCA\Contacts\Utils\TemporaryPhoto as BaseTemporaryPhoto, OCP\AppFramework\Http; /** * This class loads an image from the virtual file system. */ class FileSystem extends BaseTemporaryPhoto { /** * The virtual file system path to load the image from * * @var string */ protected $path; public function __construct(\OCP\IServerContainer $server, $path) { \OCP\Util::writeLog('contacts', __METHOD__.' path: ' . $path, \OCP\Util::DEBUG); if (!is_string($path)) { throw new \Exception( __METHOD__ . ' Second argument must a string' ); } parent::__construct($server); $this->path = $path; $this->processImage(); } /** * Load the image. */ protected function processImage() { $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); } }