Get a file's information (type, size, filename)

@param $fid
@return FileMeta
@throws SeaweedFSException
548307
public function meta($fid) {
        $cacheKey = 'file_meta_' . $fid;

        if ($this->cache && $this->cache->has($cacheKey)) {
            $val = $this->cache->get($cacheKey);

            if (!$val instanceof FileMeta) {
                $val = new FileMeta($val);
            }

            return $val;
        }

        $volume = $this->lookup($fid);

        if (!$volume) {
            return null;
        }

        $res = $this->client->head($this->buildVolumeUrl($volume->getPublicUrl(), $fid));

        if ($res->getStatusCode() != 200) {
            return null;
        }

        $meta = new FileMeta(
            $res->getHeaderLine('Content-Type'),
            $res->getHeaderLine('Content-Length'),
            new \DateTime($res->getHeaderLine('Last-Modified'))
        );

        if ($this->cache) {
            $this->cache->put($cacheKey, $meta);
        }

        return $meta;
    }
1386
public static function getTypes($fid)
  {
    $parts = explode(':', $fid);
    switch(count($parts))
    {
      case 5:
        return [$parts[1], $parts[2]];
      case 4:
        return [$parts[1], $parts[1]];
      default:
        throw new InvalidFidException("Invalid FID Passed '$fid'", 500);
    }
  }
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';
    }
841217
public static function getRelativePathFromID($fID)
    {
        $result = false;
        if ($fID) {
            $cache = Application::getFacadeApplication()->make('cache/request');
            /** @var \Concrete\Core\Cache\Cache $cache */
            if ($cache->isEnabled()) {
                $cacheItem = $cache->getItem('file_relative_path/' . $fID);
                if (!$cacheItem->isMiss()) {
                    return $cacheItem->get();
                }
            }
            $f = static::getByID($fID);
            if ($f !== null) {
                $result = $f->getRelativePath();
                if (isset($cacheItem)) {
                    $cacheItem->set($result)->save();
                }
            }
        }

        return $result;
    }
757835
def delete_file(self, fid):
        
        url = self.get_file_url(fid)
        return self.conn.delete_data(url)
582149
protected function _file($id)
    {
        $instance = self::getInstance();
        $fileNmae = $instance->_idToFileName($id);
        return self::cacheDir() . $fileNmae;
    }
1188949
public function getFromId( $diskId){
        $rest = $this->getService( self::API_STORAGE_PARTITION . $diskId);
        $rest->GET();

        return $rest->getResult( models\Storage\DiskPartition::class);
    }
1314925
private static function getMimeTypeOfFile($path)
    {
        $fileInfo = finfo_open(FILEINFO_MIME_TYPE);
        $mime     = finfo_file($fileInfo, $path);
        finfo_close($fileInfo);

        return $mime;
    }
466395
public static function getSubType($fid)
  {
    $parts = explode(':', $fid);
    switch(count($parts))
    {
      case 5:
        return $parts[2];
      case 4:
        return $parts[1];
      default:
        throw new InvalidFidException("Invalid FID Passed '$fid'", 500);
    }
  }
408492
def get_file_size(self, fid):
        
        url = self.get_file_url(fid)
        res = self.conn.head(url)
        if res is not None:
            size = res.headers.get("content-length", None)
            if size is not None:
                return int(size)
        return None
1053702
public function _read($pId)
    {
        if (! isset($this->_items[$pId])) {
            $this->_items[$pId] = Agl::getModel(self::DB_COLLECTION);
            $this->_items[$pId]->loadByRealid($pId);
        }

        if ($this->_items[$pId]->getId()) {
            return $this->_items[$pId]->getData();
        }

        return '';
    }
689551
public function fidToUserId($fid) {
        $value = Cache::redis()->hGet('fid_#_user_id', $this->host_name . '@' . $fid);
        Cache::release();
        return $value;
    }
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;
    }
829378
public static function resolvetoFIDtoURI(int $fid) {

        if (!is_integer($fid)) {
            return null;
        }
        /* @var \Drupal\file\FileInterface $file */
        $file = \Drupal::entityTypeManager()->getStorage('file')->load($fid);
        return $file;
    }
805501
public BoxFile.Info getFileInfo(String fileID) {
        URL url = FILE_INFO_URL_TEMPLATE.build(this.api.getBaseURL(), fileID);
        BoxAPIRequest request = new BoxAPIRequest(this.api, url, "GET");
        BoxJSONResponse response = (BoxJSONResponse) request.send();
        JsonObject jsonObject = JsonObject.readFrom(response.getJSON());

        BoxFile file = new BoxFile(this.api, jsonObject.get("id").asString());
        return file.new Info(response.getJSON());
    }
491693
public function getFileset($id) {
    $filesets = $this->getFilesets();
    if (isset($filesets[$id])) {
      return $filesets[$id];
    }
    $this->logger->warning("Fileset $id not found");

    return NULL;
  }
174740
public function getEntry($entryId) {
        $this->gotoEntry($entryId);
        return $this->getFile()->fread(self::B_SZ);
    }