byteamagic
Detect MIME types and file formats from PostgreSQL bytea values
Repository
nmandery/pg_byteamagic
https://github.com/nmandery/pg_byteamagic
Source
pg_byteamagic-0.2.4.tar.gz
pg_byteamagic-0.2.4.tar.gz
Overview
| Package | Version | Category | License | Language |
|---|---|---|---|---|
pg_byteamagic | 0.2.4 | UTIL | BSD 2-Clause | C |
| ID | Extension | Bin | Lib | Load | Create | Trust | Reloc | Schema |
|---|---|---|---|---|---|---|---|---|
| 4275 | byteamagic | No | Yes | No | Yes | No | Yes | - |
Extension name is byteamagic; package name is pg_byteamagic.
Version
| Type | Repo | Version | PG Ver | Package | Deps |
|---|---|---|---|---|---|
| EXT | PIGSTY | 0.2.4 | 1817161514 | pg_byteamagic | - |
| RPM | PIGSTY | 0.2.4 | 1817161514 | pg_byteamagic_$v | - |
| DEB | PIGSTY | 0.2.4 | 1817161514 | postgresql-$v-pg-byteamagic | - |
Build
You can build the RPM / DEB packages for pg_byteamagic using pig build:
pig build pkg pg_byteamagic # build RPM / DEB packages
Install
You can install pg_byteamagic directly. First, make sure the PGDG and PIGSTY repositories are added and enabled:
pig repo add pgsql -u # Add repo and update cache
Install the extension using pig or apt/yum/dnf:
pig install pg_byteamagic; # Install for current active PG version
pig ext install -y pg_byteamagic -v 18 # PG 18
pig ext install -y pg_byteamagic -v 17 # PG 17
pig ext install -y pg_byteamagic -v 16 # PG 16
pig ext install -y pg_byteamagic -v 15 # PG 15
pig ext install -y pg_byteamagic -v 14 # PG 14
dnf install -y pg_byteamagic_18 # PG 18
dnf install -y pg_byteamagic_17 # PG 17
dnf install -y pg_byteamagic_16 # PG 16
dnf install -y pg_byteamagic_15 # PG 15
dnf install -y pg_byteamagic_14 # PG 14
apt install -y postgresql-18-pg-byteamagic # PG 18
apt install -y postgresql-17-pg-byteamagic # PG 17
apt install -y postgresql-16-pg-byteamagic # PG 16
apt install -y postgresql-15-pg-byteamagic # PG 15
apt install -y postgresql-14-pg-byteamagic # PG 14
Create Extension:
CREATE EXTENSION byteamagic;
Usage
Sources: GitHub repo, byteamagic docs Extension name:
byteamagicThe CSV package row ispg_byteamagic; the upstream extension name isbyteamagic.
byteamagic uses libmagic on bytea values to identify the MIME type and the file type text inside PostgreSQL.
CREATE EXTENSION byteamagic;
SELECT byteamagic_mime(data);
SELECT byteamagic_text(data);
Functions
byteamagic_mime(bytea)returns the MIME type as text and matchesfile --mime-type.byteamagic_text(bytea)returns a human-readable file type description and matchesfile.
Notes
- The extension needs PostgreSQL development headers and the
libmagicdevelopment package. - It is intended for databases that store files or blobs in
byteaand need in-database type detection.
Feedback
Was this page helpful?
Thanks for the feedback! Please let us know how we can improve.
Sorry to hear that. Please let us know how we can improve.