Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

988 B
Raw Blame
export const formatFileSize = (bytes: number): string => {
    if (bytes === 0) {
        return '0 Bytes'
    }
    const k = 1024
    const sizes = ['Bytes', 'KB', 'MB', 'GB']
    const i = Math.floor(Math.log(bytes) / Math.log(k))
    return parseFloat((bytes / Math.pow(k, i)).toFixed(2)) + ' ' + sizes[i]
}

export const getFileIcon = (type: string): string => {
    if (type.startsWith('image/')) {
        return '🖼️'
    }
    if (type.startsWith('video/')) {
        return '🎥'
    }
    if (type.startsWith('audio/')) {
        return '🎵'
    }
    if (type.includes('pdf')) {
        return '📄'
    }
    if (type.includes('word')) {
        return '📝'
    }
    if (type.includes('excel') || type.includes('spreadsheet')) {
        return '📊'
    }
    if (type.includes('powerpoint') || type.includes('presentation')) {
        return '📈'
    }
    if (type.includes('zip') || type.includes('rar')) {
        return '🗜️'
    }
    return '📁'
}