Обсуждение: [ADMIN] Data type for storing attached file

Поиск
Список
Период
Сортировка

[ADMIN] Data type for storing attached file

От
"Ferrell, Denise D CTR NSWCDD, H11"
Дата:
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


Re: [ADMIN] Data type for storing attached file

От
Tiago Dantas
Дата:
Have you tried bytea?
https://www.postgresql.org/docs/9.3/static/datatype-binary.html

On Tue, Jul 11, 2017 at 11:10 AM, 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



--
Tiago Dantas
Benefits By Design
Database Administration
Phone: 416.824.8779

This email may contain privileged or confidential information intended solely for the recipient(s) to whom it was addressed. If you received this message in error we kindly ask you not to copy or distribute it. If you are not the intended recipient of this message please notify the sender and delete this and any attachments. If you do not wish to receive further communications, you can manage your subscriptions (including the option to unsubscribe) here. If you have questions regarding the authenticity or security of this email, please do not hesitate to contact us at 1-888-272-0413.

Re: [ADMIN] Data type for storing attached file

От
Ashish Tiwari
Дата:
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

Re: [ADMIN] Data type for storing attached file

От
Bear Giles
Дата:
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