Searches for any File Storage entity by entity ID.
Result can be File, Image or Folder.

@param string $fileId
@param string $type
@return null | FileAbstraction
3540
public function find($fileId, $type = null)
	{
		if (! is_string($fileId)) {
			return null;
		}

		if (empty($type)) {
			$type = FileAbstraction::CN();
		}
		
		return $this->getDoctrineEntityManager()
				->find($type, $fileId);
	}
603671
public function get($fid, $ext = null) {
        $volume = $this->lookup($fid);

        if (!$volume) {
            return null;
        }

        $path = $fid;

        if ($ext) {
            $path = $path . '.' . $ext;
        }

        $res = $this->client->get($this->buildVolumeUrl($volume->getPublicUrl(), $path));

        if ($res->getStatusCode() != 200) {
            throw new SeaweedFSException('Unexpected response when retrieving file: ' . $res->getStatusCode());
        }

        return $res->getBody()->detach();
    }
469659
protected function getTypeById($type, $id)
    {
        $items = isset($this->$type) ? $this->$type : [];

        if (false === isset($items[$id])) {
            throw new \RuntimeException(sprintf("Unknown %s item with id '%s'", $type, $id), 404);
        }

        return $items[$id];
    }
40613
public function loadSlideFile($type, $id) {
        $query = $this->connection->select('file_usage', 'n');
        $query->fields('n', array('fid'));
        $query->condition('n.module', 'site_sliders');
        $query->condition('n.type', $type);
        $query->condition('n.id', $id);
        $fid = $query->execute()->fetchField(); 
        
        $file = NULL;
        if ($fid) {
            $file = File::load($fid);
        }     
        return $file; 
    }
1210488
protected List<FileMeta> handleGetEntityMetaFiles(Class<? extends FileEntity> type, Integer entityId) {
        Map<String, String> uriVariables = restUriVariablesFactory.getUriVariablesForGetEntityMetaFiles(
                BullhornEntityInfo.getTypesRestEntityName(type), entityId);
        String url = restUrlFactory.assembleGetEntityMetaFilesUrl();
        String jsonString = this.performGetRequest(url, String.class, uriVariables);
        EntityMetaFiles<? extends FileMeta> entityMetaFiles = restJsonConverter.jsonToEntityDoNotUnwrapRoot(jsonString,
                StandardEntityMetaFiles.class);
        if (entityMetaFiles == null || entityMetaFiles.getFileMetas() == null) {
            return Collections.emptyList();
        }
        return (List<FileMeta>) entityMetaFiles.getFileMetas();
    }
566649
private function search($itemName, $type = null)
    {
        if (null === $type) {
            $searchArray = $this->getItems();
        } elseif (self::TYPE_FILE == $type) {
            $searchArray = $this->getFiles();
        } else {
            $searchArray = $this->getFolders();
        }

        foreach ($searchArray as $id => $cloudItem) {
            if ($itemName === $cloudItem->getName()) {
                return $cloudItem;
            }
        }

        return null;
    }
403623
public static function moveFileToFolder($fileId, $folderId)
    {
        $file = StorageFile::findOne($fileId);
        
        if ($file) {
            $file->updateAttributes(['folder_id' => $folderId]);
            Yii::$app->storage->flushArrays();
            return true;
        }
        
        return false;
    }
727951
private function getFile($fileId)
    {
        if (!$fileId) {
            return null;
        }

        $volumeManager = $this->getContainer()->get('phlexible_media_manager.volume_manager');
        $volume = $volumeManager->getByFileId($fileId);
        $file = $volume->findFile($fileId);

        return $file;
    }
1038629
public static function findByFileType( $parentId, $parentType, $fileType ) {

		$fileTable = CoreTables::getTableName( CoreTables::TABLE_FILE );

		return self::queryByParent( $parentId, $parentType )->andFilterWhere( [ 'like', "$fileTable.type", $fileType ] )->all();
	}
212748
public function get($type, $file = null)
    {
        if (!isset($this->paths[$type])) {
            $method = 'get'.Utils::camelize($type).'Dir';

            if (!method_exists($this, $method)) {
                return null;
            }

            $this->set($type, $this->$method());
        }

        $path = $this->paths[$type];
        if ($file) {
            if ($path instanceof pathmanager\FallbackInterface) {
                $path = $path->resolve($file);
            } else {
                $path .= '/' . ltrim($file, '/');
            }
        }

        return $path;
    }
363048
public static function findByFileTag( $parentId, $parentType, $fileTag, $type = null ) {

		$mapTable	= static::tableName();
		$fileTable	= CoreTables::getTableName( CoreTables::TABLE_FILE );

		if( empty( $type ) ) {

			$type = CoreGlobal::TYPE_DEFAULT;
		}

		return self::queryByParent( $parentId, $parentType )->andWhere( "$fileTable.tag=:tag AND $mapTable.type=:type", [ ':tag' => $fileTag, ':type' => $type ] )->one();
	}
526158
public function setType(string $filename, $type = null): AssetFileInterface
    {
        if (! is_null($type) && in_array($type, $this->extensions, true)) {
            // We first listen to a defined asset type.
            // If no type is defined, let's try to discover it.
            $this->type = $this->findType($type);

            return $this;
        }

        $ext = $this->files->extension($filename);

        if (! empty($ext) && in_array($ext, $this->extensions, true)) {
            $this->type = $this->findType($ext);
        }

        return $this;
    }
1085481
public function view($id, $type) {
		$params = array(
			'id' => $id,
			'type' => $type
		);
		return $this->master->call('files/view', $params);
	}
916535
public function getOrganizationFileData($organizationId, $fileId)
    {
        list($response) = $this->getOrganizationFileDataWithHttpInfo($organizationId, $fileId);
        return $response;
    }
1301886
public function getFile($fileId)
    {
        $this->connect();

        $fileId = trim(trim($fileId, '/'));
        if ($fileId != '')
        {
            if (strpos($fileId, '/') === false)
            {
                $folder = $this->getFolder();
            }
            else
            {
                $pathinfo = pathinfo($fileId);
                $folder   = $this->getFolder($pathinfo['dirname']);
            }
            if ($folder)
            {
                return $folder->getFile($fileId);
            }
        }

        return false;
    }
504520
public function link($fileId)
    {
        $links = session(static::SESSION_KEY, []);

        $links[ $fileId ] = true;

        session()->put(static::SESSION_KEY, $links);

        return $this;
    }
769233
public function addFileToSet($f_id)
    {
        $app = Application::getFacadeApplication();
        if (is_object($f_id)) {
            $f = $f_id;
            if ($f instanceof FileEntity) {
                $file = $f;
                $fileVersion = $file->getApprovedVersion();
            } else {
                $fileVersion = $f;
                $file = $fileVersion->getFile();
            }
            $f_id = (int) $file->getFileID();
        } else {
            $f_id = (int) $f_id;
            $em = $app->make(EntityManagerInterface::class);
            $file = $em->find(FileEntity::class, $f_id);
            $fileVersion = $file->getApprovedVersion();
        }
        if ($file === null) {
            $result = null;
        } else {
            $file_set_file = File::createAndGetFile($f_id, $this->fsID);
            $fe = new \Concrete\Core\File\Event\FileSetFile($file_set_file);
            $director = $app->make(EventDispatcherInterface::class);
            $director->dispatch('on_file_added_to_set', $fe);
            if ($fileVersion !== null && $this->shouldRefreshFileThumbnails('add')) {
                $fileVersion->refreshThumbnails(false);
            }
            $result = $file_set_file;
        }

        return $result;
    }