album->url_alias, is_null($thumbnail) ? $this->getOriginalsFolder() : $thumbnail, $photo->storage_file_name ); } public function saveOriginal(Photo $photo, $tempFilename) { $this->saveThumbnail($photo, $tempFilename, $this->getOriginalsFolder()); } /** * Saves a generated thumbnail to its permanent location. * @param Photo $photo Photo the thumbnail relates to. * @param string $tempFilename Filename containing the thumbnail. * @param string $thumbnail Name of the thumbnail. * @return mixed */ public function saveThumbnail(Photo $photo, $tempFilename, $thumbnail) { $container = $this->getContainer(); $container->uploadObject( sprintf('%s/%s/%s', $this->album->url_alias, $thumbnail, $photo->storage_file_name), fopen($tempFilename, 'r+') ); } /** * Saves an uploaded file to the container and returns the filename. * @param File $uploadedFile The photo uploaded * @param string $overrideFilename Specific file name to use, or null to randomly generate one. * @return File */ public function saveUploadedPhoto(File $uploadedFile, $overrideFilename = null) { // TODO: Implement saveUploadedPhoto() method. } private function getClient() { return new OpenStack($this->configuration->auth_url, [ 'username' => $this->configuration->username, 'password' => decrypt($this->configuration->password), 'tenantName' => $this->configuration->tenant_name, ]); } private function getContainer() { return $this->getStorageService()->getContainer($this->configuration->container_name); } private function getOriginalsFolder() { return '_originals'; } private function getStorageService() { return $this->getClient()->objectStoreService( $this->configuration->service_name, $this->configuration->service_region, 'publicURL' ); } }