Marshall a QTI file datatype into its PCI JSON Representation.

@param \qtism\common\datatypes\File $file
@return array
425096
protected function marshallFile(QtiFile $file)
    {
        $data = array('base' => array('file' => array('mime' => $file->getMimeType(), 'data' => base64_encode($file->getData()))));

        if ($file->hasFilename() === true) {
            $data['base']['file']['name'] = $file->getFilename();
        }

        return $data;
    }
1060764
public function uploadQiniu($file)
    {
        $info = [
            'success' => 1,
            'message' => '上传成功',
            'url' => '',
        ];

        $filename = $this->getFilename($file);

        $auth = new Auth($this->qiniuAccessKey, $this->qiniuSecretKey);
        $token = $auth->uploadToken($this->qiniuBucket);

        $upManager = new UploadManager();

        list($code, $error) = $upManager->putFile($token, $filename, $file);

        if ($error) {
            $info['success'] = 0;
            $info['message'] = $error->message();
            return $info;
        }

        $info['url'] = $this->qiniuDomain . DIRECTORY_SEPARATOR . $filename;
        return $info;
    }
1294708
public static function getMimeType($file)
    {
        $finfo = finfo_open(FILEINFO_MIME_TYPE);
        $type = finfo_file($finfo, $file);
        finfo_close($finfo);

        return $type;
    }
242672
private function getBaseInfo(string $file)
    {
        $id = pathinfo($file, PATHINFO_FILENAME);
        $dir = pathinfo($file, PATHINFO_DIRNAME);
        $folder = str_replace(PATH_HOME . '_cdn/', '', $dir) . "/version";

        \Helpers\Helper::createFolderIfNoExist($dir . "/version");

        return [$id, $folder];
    }
680967
protected function processJSONForeignKeys($file)
    {
        $json = File::get($file);
        $fields = json_decode($json);

        if (! property_exists($fields, 'foreign_keys')) {
            return '';
        }

        $foreignKeysString = '';
        foreach ($fields->foreign_keys as $foreign_key) {
            $foreignKeysString .= $foreign_key->column . '#' . $foreign_key->references . '#' . $foreign_key->on;

            if (property_exists($foreign_key, 'onDelete')) {
                $foreignKeysString .= '#' . $foreign_key->onDelete;
            }

            if (property_exists($foreign_key, 'onUpdate')) {
                $foreignKeysString .= '#' . $foreign_key->onUpdate;
            }

            $foreignKeysString .= ',';
        }

        $foreignKeysString = rtrim($foreignKeysString, ',');

        return $foreignKeysString;
    }
427871
public static function file2array($file)
    {
        $aFile = [];
        if ($file instanceof UploadedFile) {
            $aFile = file($file->getRealPath());
        } elseif (is_array($file) && isset($file[0]) && is_string($file[0])) {
            $aFile = $file;
        } elseif (is_string($file) && is_file($file) && file_exists($file)) {
            $aFile = file($file);
        } elseif (is_string($file) && strstr($file, PHP_EOL) !== false) {
            $file_content = explode(PHP_EOL, $file);
            if (empty(end($file_content))) {
                array_pop($file_content);
            }
            reset($file_content);
            $aFile = $file_content;
        }

        return array_map('\ForceUTF8\Encoding::toUTF8', $aFile);
    }
803076
private static function parseRequestedFile(string $file): array
    {
        $file = ltrim($file, '/');

        $moduleConfig = Config::application('module');

        $parts    = explode('/', $file);
        $partsCnt = count($parts);

        if ($partsCnt > 0 && in_array($parts[0], Config::get('divisions'))) {
            $_division = $parts[0];
            $parts     = array_slice($parts, 1);
        } else {
            $_division = '';
        }

        $_module = empty($parts[0])
            ? $moduleConfig['default']
            : $parts[0];

        $_method = $partsCnt < 2 || empty($parts[1])
            ? $moduleConfig['defaultViewsControllerAction']
            : Str::camel($parts[1]);

        $_params = $partsCnt > 2
            ? array_slice($parts, 2)
            : [];

        return [$_division, $_module, $_method, $_params];
    }
1263121
public function transform(FileContract $file)
    {
        return [
            'id'        => $file->getId(),
            'name'      => $file->getName(),
            'mime_type' => $file->getMimeType(),
            'byte_size' => $file->getByteSize(),
            'data'      => $file->getData(),
            'saved_at'  => $file->getSavedAt(),
        ];
    }
251673
private function getFileContents($file) {
		$content = file_get_contents($file);

		// Remove UTF-8 BOM
		if (substr($content, 0, 3) === pack("CCC", 0xef, 0xbb, 0xbf))
			$content = substr($content, 3);

		return $content;
	}
1275273
public static function getMime($file)
    {
        $fileInfo = finfo_open(FILEINFO_MIME_TYPE);
        $mime = finfo_file($fileInfo, $file);

        return empty($mime) ? : $mime;
    }
1271821
public static function get($file)
    {
        $type = str_replace('image/', NULL, Singleton::class('ZN\Helpers\Mime')->type($file));

        return $type === 'jpg' ? 'jpeg' : $type;
    }
698108
private function getMimeType($file)
    {
        $type = FileInfo::DIRECTORY_MIME_TYPE;
        if (is_file($file)) {
            if (class_exists('finfo')) {
                $finfo = new \finfo(FILEINFO_MIME);
                $type = $finfo->file($file);
            } else {
                $type = MimeType::getTypeByExt(pathinfo($file, PATHINFO_EXTENSION));
            }
        }
        $type = strstr($type, ';', true) ?: $type;

        return isset(MimeType::$internalType[$type]) ? MimeType::$internalType[$type] : $type;
    }
1014428
protected function readConfigurationFile($file)
    {
        if (! file_exists($file)) {
            throw InvalidSetupException::confNotFound($file);
        }
        if (! $json = file_get_contents($file)) {
            throw InvalidSetupException::confNotReadable($file);
        }
        if (! $config = json_decode($json)) {
            throw InvalidSetupException::confNotJson($file);
        }
        sodium_memzero($json);
        return $config;
    }
758459
public function get_mime($file){
        $type = $this->get_content_type($file);
        if( $type ){
            $type = array_map('trim', explode(';', $type));
            return $type[0];
        }else{
            return '';
        }
    }
315164
function &read($file) {
		if (!$this->dir || !is_file($dst=$this->dir.$file)) {
			if (!isset($this->data[$file]))
				$this->data[$file]=[];
			return $this->data[$file];
		}
		if ($this->lazy && isset($this->data[$file]))
			return $this->data[$file];
		$fw=\Base::instance();
		$raw=$fw->read($dst);
		switch ($this->format) {
			case self::FORMAT_JSON:
				$data=json_decode($raw,TRUE);
				break;
			case self::FORMAT_Serialized:
				$data=$fw->unserialize($raw);
				break;
		}
		$this->data[$file] = $data;
		return $this->data[$file];
	}
398469
public function transform($file)
    {
        $thumb = null;

        if ($file->type === 'image') {
            $width  = config('gzero.image.thumb.width');
            $height = config('gzero.image.thumb.height');
            $thumb  = croppaUrl($file->getFullPath(), $width, $height);
        }

        $file = $this->entityToArray(File::class, $file);
        return [
            'id'        => (int) $file['id'],
            'type'      => $file['type'],
            'name'      => $file['name'],
            'extension' => $file['extension'],
            'size'      => (int) $file['size'],
            'mimeType'  => $file['mime_type'],
            'info'      => $file['info'],
            'thumb'     => $thumb,
            'weight'    => $this->setPivotNullableValue($file, 'weight'),
            'isActive'  => (bool) $file['is_active'],
            'createdBy' => (int) $file['created_by'],
            'createdAt' => $file['created_at'],
            'updatedAt' => $file['updated_at']
        ];
    }
218036
public function fileinfo($file, $language = 'de')
    {
        if (!$file) {
            return [];
        }

        $parts = explode(';', $file);
        $fileId = $parts[0];

        $volume = $this->volumeManager->getByFileId($fileId);
        $file = $volume->findFile($fileId);

        if (!$file) {
            return [];
        }

        $attributes = $file->getAttributes();

        $info = [
            'name' => $file->getName(),
            'mimetype' => $file->getMimeType(),
            'mediaCategory' => $file->getMediaCategory(),
            'mediaType' => $file->getMediaType(),
            'size' => $file->getSize(),
            'attributes' => !empty($attributes['fileattributes']) ? $attributes['fileattributes'] : array(),
            'createdAt' => $file->getCreatedAt(),
            'modifiedAt' => $file->getModifiedAt(),
            'meta' => [],
        ];

        $metasets = $this->metaSetResolver->resolve($file);
        $meta = array();
        foreach ($metasets as $metaset) {
            $metadata = $this->metaDataManager->findByMetaSetAndFile($metaset, $file);
            $data = [];
            foreach ($metaset->getFields() as $field) {
                $value = '';
                if ($metadata) {
                    $value = $metadata->get($field->getName(), $language);
                }
                $data[$field->getName()] = $value;
            }
            $meta[$metaset->getName()] = $data;
        }

        $info['meta'] = new MetaSetAccessor($meta);

        return $info;
    }