Returns the uploaded file if it is present.

@param int $draftid
@return stored_file|null
180010
protected function get_cohort_file($draftid) {
        global $USER;
        // We can not use moodleform::get_file_content() method because we need the content before the form is validated.
        if (!$draftid) {
            return null;
        }
        $fs = get_file_storage();
        $context = context_user::instance($USER->id);
        if (!$files = $fs->get_area_files($context->id, 'user', 'draft', $draftid, 'id DESC', false)) {
            return null;
        }
        $file = reset($files);

        return $file;

    }
51011
public function getOnPaymentSubmit($storeId = null)
    {
        return $this->getScopeConfig()->getValue(
            self::XML_PATH_TRACK_PAYMENT_SUBMIT,
            ScopeInterface::SCOPE_STORE,
            $storeId
        );
    }
279223
public function fileAction($storageId)
    {
        $fileManager = $this->get('beaast.core.manager.file');

        /**
         * @var File $file
         */
        $file = $fileManager->findOneBy(['storageId' => $storageId]);

        if (!$file) {
            return new Response('File not found.', 404);
        }

        $filePath = $fileManager->getFilePath($file);

        $headers = array();
        if ($file->getExtension() === 'png') {
            $headers = array(
                'Content-Type'     => 'image/png',
                'Content-Disposition' => 'inline; filename="'.$file->getFileName().'"',
            );
        } elseif ($file->getExtension() === 'jpg') {
            $headers = array(
                'Content-Type'     => 'image/jpg',
                'Content-Disposition' => 'inline; filename="'.$file->getFileName().'"',
            );
        } elseif ($file->getExtension() === 'pdf' || $file->getExtension() === 'xlsx') {
            $headers = array(
                'Cache-Control'     => 'private',
                'Content-Type'     => $file->getMimeType(),
                'Content-length'     => $file->getSize(),
                'Content-Disposition' => 'attachment; filename="'.$file->getFileName().'"',
            );
        }

        return new Response(file_get_contents($filePath), 200, $headers);
    }
366931
public function read($sessionID)
    {
        $fileName = $this->getFileName($sessionID);
        if(is_file($fileName))
        {
            return Coroutine::readFile($fileName);
        }
        else
        {
            return '';
        }
    }
839825
public function getEntry($entryId) {
        list($entryId, $len) = $this->gotoEntry($entryId);
        if ($entryId === false) {
            return '';
        }
        return $this->getFile()->fread($len);
    }
253932
protected function store_empty_document($contextid, $itemid) {
        // Store the file.
        $record = $this->get_stored_file_record($contextid, $itemid);
        $fs = get_file_storage();

        // Delete existing files first.
        $fs->delete_area_files($record->contextid, $record->component, $record->filearea, $record->itemid);

        $file = $fs->create_file_from_string($record, base64_decode(document_services::BLANK_PDF_BASE64));
        $this->pagecount = 1;

        $this->set_combined_file($file);

        return $this;
    }
1066952
public function getRound($roundId)
    {
        $this->_ensureRounds();

        if (! isset($this->_rounds[$roundId])) {
            return null;
        }
        if (! isset($this->_roundObjects[$roundId])) {
            $this->_roundObjects[$roundId] = $this->tracker->createTrackClass('Round', $this->_rounds[$roundId]);
        }
        return $this->_roundObjects[$roundId];
    }
174740
public function getEntry($entryId) {
        $this->gotoEntry($entryId);
        return $this->getFile()->fread(self::B_SZ);
    }
345327
public function getFromId($FileUploadId)
    {
        $rest = $this->callService('GET', self::API_UPLOAD . $FileUploadId);

        return $rest->getModel(models\FileSystem\FileUpload::class);
    }
106630
public function getFilterData($filterId = null)
    {
        if ($filterId !== null) {
            foreach ($this->filterData as $filter) {
                if ($filter->getId() == $filterId) {
                    return $filter;
                }
            }
            return null;
        } else {
            return $this->filterData;
        }
    }
494708
public function guessFileType(FileId $fileId)
    {
        $extension = strtolower(\pathinfo($fileId->id(), PATHINFO_EXTENSION));

        foreach($this->fileTypeExtensions as $fileType => $extensions) {
            if(in_array($extension, $extensions)) {
                return $fileType;
            }
        }

        return 'file';
    }
369498
public function getCdnUrl($storeId = null)
    {
        //Check for sandbox mode
        if ($this->isSandboxModeSet($storeId)) {
            return self::CDN_URL_SANDBOX;
        } else {
            return self::CDN_URL_PRODUCTION;
        }
    }
1135069
public function actionDataFiles($folderId = 0, $search = null)
    {
        $query = StorageFile::find()
            ->select(['id', 'name_original', 'extension', 'upload_timestamp', 'file_size', 'mime_type'])
            ->where(['is_hidden' => false, 'is_deleted' => false])
            ->with(['images.file']);

        if (!empty($search)) {
            $query->andFilterWhere(['or', 
                ['like', 'name_original', $search],
                ['like', 'caption', $search],
                ['=', 'id', $search],
            ]);
        } else {
            $query->andWhere(['folder_id' => $folderId]);
        }

        return new ActiveDataProvider([
            'query' => $query,
        ]);
    }
690298
public function get($id)
    {
        $document = $this->getFileCollection()->findOne(['_id' => $id]);
        return empty($document) ? null : $this->createDownload($document);
    }
1259360
public function getOrderFileList($orderId)
    {
        $orderFileList = oxNew(OrderFileList::class);
        $orderFileList->loadOrderFiles($orderId);

        if (count($orderFileList) > 0) {
            return $orderFileList;
        }

        return false;
    }
285397
public function get(string $name): ?UploadedFileInterface
    {
        if (!isset($this->uploadedFiles[$name])) {
            return null;
        }

        return $this->uploadedFiles[$name];
    }
110600
protected function getVariant($fileID)
    {
        $parsedFiledID = $this->getPublicResolutionStrategy()->parseFileID($fileID);
        return $parsedFiledID ? $parsedFiledID->getVariant() : null;
    }