Re: [ADMIN] Data type for storing attached file

Поиск
Список
Период
Сортировка
От Bear Giles
Тема Re: [ADMIN] Data type for storing attached file
Дата
Msg-id CALBNtw5tzE1Wycc3z6w6_84oSAkE1zjNS=JoQAyQPW6mpkmnyg@mail.gmail.com
обсуждение исходный текст
Ответ на Re: [ADMIN] Data type for storing attached file  (Ashish Tiwari <tashish786@gmail.com>)
Список pgsql-admin
If you want to get fancy you can create a "user defined type" for each type of attachment. A very vanilla implementation would just make it a little easier to figure out what you have but a RECORD type would allow you to cache "interesting" information (e.g., the size of an image in pixels) and a full implementation in C, java, etc., could compute that "interesting" information from the raw data and even perform different types of manipulation. E.g., you could have a "user defined function" that rescales the image to a desired size.

The downsides are that few frameworks understand UDT.  That's not a problem if you're writing everything by hand or are able to use hand-written code for specific functionality but could be a problem if you're trying to do everything via a framework.

Another potential downside is if you don't host your own instance, e.g., you're using an AWS RDS instance. They won't allow you to use "C" extensions. (You can still use pure SQL extensions.)

Finally if you want to be generic - you want "attachments" but don't want to require explicit types, you can either use a generic UDT or create a polymorphic one where the DB sees the UDT but you have UDF that allow you to cast the type to a specific format if possible.

On Tue, Jul 11, 2017 at 9:31 AM, Ashish Tiwari <tashish786@gmail.com> wrote:
Hi Ferrell , 

I have encoded the files in base64 and stored binary data in text.this can be stored in bytea too.

Thanks.

On Jul 11, 2017 8:41 PM, "Ferrell, Denise D CTR NSWCDD, H11" <denise.ferrell.ctr@navy.mil> wrote:
Using PostgreSQL v9.3 on Linux...

What data type would be used to store an attachment (file, could be .txt, .doc, .xls, etc.) into a column?

Thank you in advance,
Denise


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

В списке pgsql-admin по дате отправления:

Предыдущее
От: Ashish Tiwari
Дата:
Сообщение: Re: [ADMIN] Data type for storing attached file
Следующее
От: ghiureai
Дата:
Сообщение: [ADMIN] autovacuum logs question