Retrieve path.

@author Casper Rasmussen <cr@nodes.dk>

@param  \Symfony\Component\HttpFoundation\File\UploadedFile $uploadedFile
@param  \Nodes\Assets\Upload\Settings                       $settings

@return string
550941
private function getPath(UploadedFile $uploadedFile, Settings $settings)
    {
        return env('APP_NAME').DIRECTORY_SEPARATOR.$this->getSubFolder($uploadedFile).DIRECTORY_SEPARATOR.$settings->getFolder();
    }
1011250
private function getExtension(UploadedFile $file): ?string
    {
        $originalName = $file->getClientOriginalName();

        if ($extension = pathinfo($originalName, PATHINFO_EXTENSION)) {
            return strtolower($extension);
        }

        if ($extension = $file->guessExtension()) {
            return strtolower($extension);
        }

        return null;
    }
511715
public function getStoragePath()
    {
        $path = $this->getOption('storage_path');
        $path = $path ? $path : storage_path().'/administrator_settings/';

        return rtrim($path, '/').'/';
    }
885256
private function uploadFile(UploadedFile $file)
    {
        /** @var FileStorage $fileStorage */
        $fileStorage = Yii::$app->get('fileStorage');

        $filename = $fileStorage->saveUploadedFile($file);

        return $fileStorage->put($filename, $file->name);
    }
35362
public static function uploadImage(UploadedFile $uploadedFile, $context, $storage = 'local', $fileName = null)
    {
        $file = Facades\File::get($uploadedFile);
        /** @var Processor $processor */
        $processor = app('icr.processor');
        return $processor->upload(
            $context,
            $file,
            $uploadedFile->getClientOriginalExtension(),
            Facades\Storage::disk($storage),
            $fileName
        );
    }
431595
protected function getPayload(Settings $settings) : array
    {
        $settings->hasRequiredSettings();

        $now = Carbon::now()->toDateTimeString();

        if ($this->config->get('tracker.save_rendered', true) && $settings->data !== null) {
            $rendered = markdown($settings->data);
        }

        return [
            'user_id'           => $settings->user,
            'ipv4'              => $settings->ipv4(),
            'user_agent'        => $settings->userAgent(),
            'request_method'    => $settings->requestMethod(),
            'request_url'       => $settings->requestUrl(),
            'type'              => strtolower($settings->type),
            'type_id'           => $settings->typeId,
            'item_id'           => $settings->itemId,
            'level'             => (int) $settings->flagLevel,
            'trackable_type'    => $settings->trackType !== Tracker::TRACKER_ANY ? $settings->trackType : Tracker::TRACKER_TRAIL,
            'data'              => $settings->data,
            'data_rendered'     => $rendered ?? null,
            'created_at'        => $now,
            'updated_at'        => $now,
        ];
    }
151206
protected function createOutput(Settings $settings) : string
    {
        return StrFormat::format(
            '{{scheme}}{{domain}}{{path}}{{query}}{{fragment}}',
            $this->parseUrlComponents($settings),
            new StrSettings([ 'removeUnparsed' => true ])
        );
    }
145125
public function getUploadPath(UploadedFile $file)
    {
        if (($path = $this->uploadPath)) {
            if (is_callable($path)) {
                $path = call_user_func($path, $file);
            }

            return trim($path, '/');
        }

        return $this->getDefaultUploadPath($file);
    }
1005613
public static function getDataUriFromUploadedFile(UploadedFile $file)
    {
        return sprintf('data:%s;base64,%s', $file->getMimeType(), base64_encode(file_get_contents($file->getPathname())));
    }
863089
protected function getLocalResourceRepositoryKey(ResourceSettings $settings) : string
    {
        return sprintf(
            'styles.local.%s.%s.%d',
            $settings->theme->getKey(),
            $this->crcCache($settings->media),
            $settings->order
        );
    }
228790
private function getCacheKey(array $assets, array $settings): string
    {
        $keys = [];
        foreach ($assets as $file) {
            $keys[] = sha1_file($file);
        }
        $keys[] = sha1(serialize($settings));

        return sha1(implode('', $keys));
    }
550352
protected function getSessionSavePath($toAppend = null)
    {
        // load the default path
        $sessionSavePath = $this->getSessionSettings()->getSessionSavePath();

        // check if we've something to append
        if ($toAppend != null) {
            $sessionSavePath = $sessionSavePath . DIRECTORY_SEPARATOR . $toAppend;
        }

        // return the session save path
        return $sessionSavePath;
    }
270050
private function validateExtension(UploadedFile $uploadedFile) {
        $pathInfo = pathinfo($uploadedFile->getName());
        if(!isset($pathInfo['extension'])) {
            throw new Exception('No Extension Found(' . $uploadedFile->getName() . ')', 401);
        }
        $extension = strtolower($pathInfo['extension']);
        if(!in_array($extension, $this->getAllowedExtensions())) {
            throw new Exception('Invalid Type of File Uploaded, valid types: ' . implode(', ', $this->getAllowedExtensions()), 401);
        }
    }
1169699
public static function addForm($settings = [])
    {
        $form = self::createElement('form');

        if (array_get($settings, 'file_upload')) {
            $form->addElement('input')->type('hidden')->name('MAX_FILE_SIZE')->value(self::getFileUploadMaxSize());
        }

        return $form;
    }
430238
public function upload(UploadedFile $file = null)
    {
        if ($file === null) {
            return '';
        }

        $fileName = $this->getFileName($file);
        $file->move($this->getTargetDir(), $fileName);

        return $fileName;
    }
272218
public function setFile(UploadedFile $file = null)
    {
        $this->file = $file;

        if (null === $this->getFile()) {
            return null;
        }

        // check if we have an old image path
        if (isset($this->path)) {
            // store the old name to delete after the update
            $this->temp = $this->path;
            $this->path = null;
        } else {
            $this->path = 'initial';
        }

        return $this;
    }
710723
private function saveOriginalFile(UploadedFile $uploadedFile)
    {
        try {
            $targetFilepath = implode('/', [
                $this->results['path'], $this->results['filename'],
            ]);

            $image = $this->intervention->make($uploadedFile);

            if ($this->exif && ! empty($image->exif())) {
                $this->results['exif'] = $image->exif();
            }

            $image->save($targetFilepath, $this->quality);

            // Save to s3
            $s3_url = $this->saveToS3($image, $targetFilepath);

            $this->results['original_width'] = (int) $image->width();
            $this->results['original_height'] = (int) $image->height();
            $this->results['original_filepath'] = $targetFilepath;
            $this->results['original_filedir'] = $this->getRelativePath($targetFilepath);
            $this->results['s3_url'] = $s3_url;
        } catch (Exception $e) {
            throw new ImageuploadException($e->getMessage());
        }

        return $this;
    }