pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
keeping images in a bytea field on AWS RDS
5+ messages / 4 participants
[nested] [flat]

* keeping images in a bytea field on AWS RDS
@ 2020-03-31 19:49 Richard Bernstein <richb201@gmail.com>
  2020-03-31 19:51 ` Re: keeping images in a bytea field on AWS RDS Christophe Pettus <xof@thebuild.com>
  2020-03-31 20:48 ` Re: keeping images in a bytea field on AWS RDS Alan Hodgson <ahodgson@lists.simkin.ca>
  2020-03-31 20:52 ` Re: keeping images in a bytea field on AWS RDS Ron <ronljohnsonjr@gmail.com>
  0 siblings, 3 replies; 5+ messages in thread

From: Richard Bernstein @ 2020-03-31 19:49 UTC (permalink / raw)
  To: pgsql-general@lists.postgresql.org

I am using postgresql on RDS. I need to upload an image to the table. I
understand that I need to set the PGDATA directory and place the image file
in it, before setting the path in the bytea field. But how do I set PGDATA
if I don't have the ability to set an environment variable, and don't have
access to the following on an AWS controlled installation?

$ initdb -D /usr/local/pgsql/data or


pg_ctl -D /usr/local/pgsql/data initdb

^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: keeping images in a bytea field on AWS RDS
  2020-03-31 19:49 keeping images in a bytea field on AWS RDS Richard Bernstein <richb201@gmail.com>
@ 2020-03-31 19:51 ` Christophe Pettus <xof@thebuild.com>
  2 siblings, 0 replies; 5+ messages in thread

From: Christophe Pettus @ 2020-03-31 19:51 UTC (permalink / raw)
  To: Richard Bernstein <richb201@gmail.com>; +Cc: pgsql-general@lists.postgresql.org



> On Mar 31, 2020, at 12:49, Richard Bernstein <richb201@gmail.com> wrote:
> 
> I am using postgresql on RDS. I need to upload an image to the table. I understand that I need to set the PGDATA directory and place the image file in it, before setting the path in the bytea field. But how do I set PGDATA if I don't have the ability to set an environment variable, and don't have access to the following on an AWS controlled installation?

No, that's not how you upload images to a bytea field; you use the standard client library and send the bytea data over that way.  It works the same on community PostgreSQL and RDS.  PostgreSQL handles managing the bytea data for you.  Note that for very large binary objects, storing them in the database is not going to be very efficient versus keeping them in the filesystem (noting, of course, that you don't have access to the filesystem of an RDS server).

--
-- Christophe Pettus
   xof@thebuild.com






^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: keeping images in a bytea field on AWS RDS
  2020-03-31 19:49 keeping images in a bytea field on AWS RDS Richard Bernstein <richb201@gmail.com>
@ 2020-03-31 20:48 ` Alan Hodgson <ahodgson@lists.simkin.ca>
  2 siblings, 0 replies; 5+ messages in thread

From: Alan Hodgson @ 2020-03-31 20:48 UTC (permalink / raw)
  To: pgsql-general@lists.postgresql.org

On Tue, 2020-03-31 at 15:49 -0400, Richard Bernstein wrote:
> I am using postgresql on RDS. I need to upload an image to the table.
> I understand that I need to set the PGDATA directory and place the
> image file in it, before setting the path in the bytea field. But how
> do I set PGDATA if I don't have the ability to set an
> environment variable, and don't have access to the following on an AWS
> controlled installation?

You don't put a file path into a bytea field or do anything with the
database filesystem. You insert the contents of the actual file into the
field using SQL commands.

^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: keeping images in a bytea field on AWS RDS
  2020-03-31 19:49 keeping images in a bytea field on AWS RDS Richard Bernstein <richb201@gmail.com>
@ 2020-03-31 20:52 ` Ron <ronljohnsonjr@gmail.com>
  2020-03-31 20:58   ` Re: keeping images in a bytea field on AWS RDS Christophe Pettus <xof@thebuild.com>
  2 siblings, 1 reply; 5+ messages in thread

From: Ron @ 2020-03-31 20:52 UTC (permalink / raw)
  To: pgsql-general@lists.postgresql.org

On 3/31/20 2:49 PM, Richard Bernstein wrote:
> I am using postgresql on RDS. I need to upload an image to the table. I 
> understand that I need to set the PGDATA directory and place the image 
> file in it, before setting the path in the bytea field. But how do I set 
> PGDATA if I don't have the ability to set an environment variable, and 
> don't have access to the following on an AWS controlled installation?
>
> $  initdb -D /usr/local/pgsql/data

> or
> pg_ctl -D /usr/local/pgsql/data initdb

initdb is definitely *not* what you want to do just to load an image into an 
exiting database.

-- 
Angular momentum makes the world go 'round.

^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: keeping images in a bytea field on AWS RDS
  2020-03-31 19:49 keeping images in a bytea field on AWS RDS Richard Bernstein <richb201@gmail.com>
  2020-03-31 20:52 ` Re: keeping images in a bytea field on AWS RDS Ron <ronljohnsonjr@gmail.com>
@ 2020-03-31 20:58   ` Christophe Pettus <xof@thebuild.com>
  0 siblings, 0 replies; 5+ messages in thread

From: Christophe Pettus @ 2020-03-31 20:58 UTC (permalink / raw)
  To: PostgreSQL General <pgsql-general@lists.postgresql.org>


> On Mar 31, 2020, at 13:52, Ron <ronljohnsonjr@gmail.com> wrote:
> initdb is definitely not what you want to do just to load an image into an exiting database.

I think there may be some confusion on the OP's part because many sources give out *advice* to put a filesystem path, rather than the entire actual binary object, into the database... and that's still good advice, even on RDS!  It just means that path needs to be a URI or some other piece of metadata that points to a different server, rather than the RDS server.

--
-- Christophe Pettus
   xof@thebuild.com






^ permalink  raw  reply  [nested|flat] 5+ messages in thread


end of thread, other threads:[~2020-03-31 20:58 UTC | newest]

Thread overview: 5+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2020-03-31 19:49 keeping images in a bytea field on AWS RDS Richard Bernstein <richb201@gmail.com>
2020-03-31 19:51 ` Christophe Pettus <xof@thebuild.com>
2020-03-31 20:48 ` Alan Hodgson <ahodgson@lists.simkin.ca>
2020-03-31 20:52 ` Ron <ronljohnsonjr@gmail.com>
2020-03-31 20:58   ` Christophe Pettus <xof@thebuild.com>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox