Re: Storing Media Types

From: "David Johnston" <polobo(at)yahoo(dot)com>
To: "'Carlos Mennens'" <carlos(dot)mennens(at)gmail(dot)com>
Cc: <pgsql-general(at)postgresql(dot)org>
Subject: Re: Storing Media Types
Date: 2011-02-10 03:16:33
Message-ID: 008601cbc8d0$ebbdfa40$c339eec0$@yahoo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Photos/Images are binary data and thus should be placed into a "bytea" typed
field. As to HOW you would identify and load the binary data that would be
depending upon your programming language and user interface. If you are
using a traditional programming language you would simply create a
parameterized INSERT statement and then specify that the contents of the
binary file would be loaded into that particular parameter.

You do NOT explicitly put the binary data into the PostgreSQL's data
directory (which you appear to be implying).

IF you want to use psql/pgAdmin running on the server to load in a local
file you should specify that and wait (or look) for a proper response as I
do not know how or if that can be done.

David J

-----Original Message-----
From: pgsql-general-owner(at)postgresql(dot)org
[mailto:pgsql-general-owner(at)postgresql(dot)org] On Behalf Of Carlos Mennens
Sent: Wednesday, February 09, 2011 7:30 PM
To: pgsql-general(at)postgresql(dot)org
Subject: [GENERAL] Storing Media Types

I've created a basic table called 'employees' & I've been asked to store a
profile photo of all employees. I've looked on Google and the
9.0 documentation but can't find any clear instructions on how I would be to
insert photo's stored in a local directory on the server
(/var/lib/postgres/data/media/pics). I'm trying to understand how I would
create an entry into the table I show below to be able to add photo's for
each user. Does anyone have an example of what the code would look like and
or offer any assistance?

ghost=> CREATE TABLE employees
(
id INT PRIMARY KEY NOT NULL UNIQUE,
fname VARCHAR(50) NOT NULL,
lname VARCHAR(50) NOT NULL,
email VARCHAR(50) UNIQUE NOT NULL,
branch VARCHAR(50) NOT NULL,
position VARCHAR(50) NOT NULL,
office INT NOT NULL,
dob DATE NOT NULL,
photo ?
)
;
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index
"employees_pkey" for table "employees"
NOTICE: CREATE TABLE / UNIQUE will create implicit index
"employees_email_key" for table "employees"
CREATE TABLE

-Carlos

--
Sent via pgsql-general mailing list (pgsql-general(at)postgresql(dot)org) To make
changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2011-02-10 04:37:08 Re: 9.0.X FOR UPDATE|SHARE on Sub-Query Causes "cannot extract system attribute from virtual tuple" if Sub-Query Returns Records (BUG)
Previous Message Joshua Tolley 2011-02-10 01:02:49 Re: How to retrieve values of 'array' field using C library (libpq)