protected function prepareUploadedFileForImport(array $uploadInfo)
    {
        $openBasedirEnabled = (boolean)ini_get('open_basedir');
        $temporaryTargetPathAndFilename = $uploadInfo['tmp_name'];
        $pathInfo = UnicodeFunctions::pathinfo($uploadInfo['name']);

        if (!is_uploaded_file($temporaryTargetPathAndFilename)) {
            throw new Exception('The given upload file "' . strip_tags($pathInfo['basename']) . '" was not uploaded through PHP. As it could pose a security risk it cannot be imported.', 1422461503);
        }

        if (isset($pathInfo['extension']) && array_key_exists(strtolower($pathInfo['extension']), $this->settings['uploadExtensionBlacklist']) && $this->settings['uploadExtensionBlacklist'][strtolower($pathInfo['extension'])] === true) {
            throw new Exception('The extension of the given upload file "' . strip_tags($pathInfo['basename']) . '" is blacklisted. As it could pose a security risk it cannot be imported.', 1447148472);
        }

        if ($openBasedirEnabled === true) {
            // Move uploaded file to a readable folder before trying to read sha1 value of file
            $newTemporaryTargetPathAndFilename = $this->environment->getPathToTemporaryDirectory() . 'ResourceUpload.' . Algorithms::generateRandomString(13) . '.tmp';
            if (move_uploaded_file($temporaryTargetPathAndFilename, $newTemporaryTargetPathAndFilename) === false) {
                throw new Exception(sprintf('The uploaded file "%s" could not be moved to the temporary location "%s".', $temporaryTargetPathAndFilename, $newTemporaryTargetPathAndFilename), 1375199056);
            }
            $temporaryTargetPathAndFilename = $newTemporaryTargetPathAndFilename;
        }

        if (!is_file($temporaryTargetPathAndFilename)) {
            throw new Exception(sprintf('The temporary file "%s" of the file upload does not exist (anymore).', $temporaryTargetPathAndFilename), 1375198998);
        }

        return [
            'filepath' => $temporaryTargetPathAndFilename,
            'filename' => $pathInfo['basename']
        ];
    }