Pimcore\Model\Asset::getFileSize PHP Method

getFileSize() public method

Get filesize
public getFileSize ( string $format = 'noformatting', $precision = 2 ) : string
$format string ('GB','MB','KB','B')
return string
    public function getFileSize($format = 'noformatting', $precision = 2)
    {
        $format = strtolower($format);
        $bytes = 0;
        if (is_file($this->getFileSystemPath())) {
            $bytes = filesize($this->getFileSystemPath());
        }
        switch ($format) {
            case 'gb':
                $size = $bytes / 1024 / 1024 / 1024;
                break;
            case 'mb':
                $size = $bytes / 1024 / 1024;
                break;
            case 'kb':
                $size = $bytes / 1024;
                break;
            case 'b':
            default:
                $size = $bytes;
                $precision = 0;
                break;
        }
        if ($format == "noformatting") {
            return $size;
        }
        return round($size, $precision) . ' ' . $format;
    }